validate
validate copied to clipboard
Turn `validate::violation`s into conditions
I'd like to signal a condition for each violation, and also re-throw error/warnings generated during validation. Is it within scope that validate
supports the following?
rules <- validator(speed >= 0
, dist >= 0
, speed/dist <= 1.5
, cor(speed, dist)>=0.2)
violations <- as.data.frame(confront(cars, rules)) %>%
dplyr::filter(value == FALSE)
tryCatch({
violation_to_warning(violations)
# violation_to_error(violations) ... etc
},
validation_violation = function(cnd){
print(cnd)
# sink_to_log(cnd) or sth else
})
Hi, I think this would be out of scope for the package.
Regarding the warnings/errors generated during validation, you can have them thrown by setting an option, validate(data, rules, raise="all"
)