validate icon indicating copy to clipboard operation
validate copied to clipboard

`validate::contains_exactly()` detects invalid syntax but `contains_exactly()` doesn't

Open SteadyGiant opened this issue 3 years ago • 1 comments

validate::contains_exactly() "fails" (warns there's invalid syntax, 0 confrontations). contains_exactly() works as expected. Other functions work fine with the validate:: bit. Is this a feature or a bug? I use <package>::function() for stylistic reasons.

library(validate)

tb = data.frame(x = c(1:3, 2), y = 4:7)
tb2 = data.frame(x = 1:2)

# This fails
rules1 = validate::validator(
  validate::contains_exactly(tb2[, "x"], allow_duplicates = TRUE)
)
#> Warning: Invalid syntax detected, the following expressions have been ignored:
#> [001] validate::contains_exactly(tb2[, "x"], allow_duplicates = TRUE)
validate::confront(tb, rules1)
#> Object of class 'validation'
#> Call:
#>     validate::confront(dat = tb, x = rules1)
#> 
#> Confrontations: 0
#> With fails    : 0
#> Warnings      : 0
#> Errors        : 0

# This works
rules2 = validate::validator(
  contains_exactly(tb2[, "x"], allow_duplicates = TRUE)
)
validate::confront(tb, rules2)
#> Object of class 'validation'
#> Call:
#>     validate::confront(dat = tb, x = rules2)
#> 
#> Confrontations: 1
#> With fails    : 0
#> Warnings      : 0
#> Errors        : 1

Created on 2021-01-12 by the reprex package (v0.3.0)

Session info
sessionInfo()
#> R version 4.0.3 (2020-10-10)
#> Platform: x86_64-w64-mingw32/x64 (64-bit)
#> Running under: Windows 10 x64 (build 19041)
#> 
#> Matrix products: default
#> 
#> locale:
#> [1] LC_COLLATE=English_United States.1252 
#> [2] LC_CTYPE=English_United States.1252   
#> [3] LC_MONETARY=English_United States.1252
#> [4] LC_NUMERIC=C                          
#> [5] LC_TIME=English_United States.1252    
#> 
#> attached base packages:
#> [1] stats     graphics  grDevices utils     datasets  methods   base     
#> 
#> other attached packages:
#> [1] validate_1.0.1
#> 
#> loaded via a namespace (and not attached):
#>  [1] compiler_4.0.3  magrittr_2.0.1  tools_4.0.3     htmltools_0.5.0
#>  [5] yaml_2.2.1      stringi_1.5.3   rmarkdown_2.6   highr_0.8      
#>  [9] grid_4.0.3      knitr_1.30      stringr_1.4.0   xfun_0.20      
#> [13] digest_0.6.27   rlang_0.4.10    settings_0.2.4  evaluate_0.14

SteadyGiant avatar Jan 12 '21 20:01 SteadyGiant

Hi same issue with validate::is_complete() vs is_complete()

Session Info

R version 4.3.1 (2023-06-16)
Platform: x86_64-pc-linux-gnu (64-bit)
Running under: Ubuntu 22.04.2 LTS

Matrix products: default
BLAS:   /usr/lib/x86_64-linux-gnu/blas/libblas.so.3.10.0 
LAPACK: /usr/lib/x86_64-linux-gnu/lapack/liblapack.so.3.10.0

locale:
 [1] LC_CTYPE=fr_FR.UTF-8       LC_NUMERIC=C              
 [3] LC_TIME=fr_FR.UTF-8        LC_COLLATE=fr_FR.UTF-8    
 [5] LC_MONETARY=fr_FR.UTF-8    LC_MESSAGES=fr_FR.UTF-8   
 [7] LC_PAPER=fr_FR.UTF-8       LC_NAME=C                 
 [9] LC_ADDRESS=C               LC_TELEPHONE=C            
[11] LC_MEASUREMENT=fr_FR.UTF-8 LC_IDENTIFICATION=C       

time zone: Europe/Paris
tzcode source: system (glibc)

attached base packages:
[1] stats     graphics  grDevices utils     datasets  methods   base     

other attached packages:
[1] validate_1.1.3

loaded via a namespace (and not attached):
[1] compiler_4.3.1 cli_3.6.1      yaml_2.3.7     grid_4.3.1     jsonlite_1.8.5
[6] rlang_1.1.1    settings_0.2.7

LBeaulaton avatar Jul 07 '23 08:07 LBeaulaton