egnha / valaddin

Functional input validation to make R functions more readable and robust
Other
33 stars 1 forks source link

Error message from validate() should display name of test object #36

Closed egnha closed 7 years ago

egnha commented 7 years ago

Example:

validate(mtcars,
         vld_all(~sapply(., is.numeric)),
         ~{nrow(.) > 1000},
         vld_all(~c("mpg", "cylinders") %in% names(.)))

#> Error: validate(. = .)
#> 1) FALSE: (function(.) {nrow(.) > 1000})(.)
#> 2) Not all TRUE: c("mpg", "cylinders") %in% names(.)

The error message should display the data frame (mtcars), rather than simply .. (It will be tricky to get this to work in a magrittr %>%-line, because of the way magrittr reduces a chain of calls.)