validate icon indicating copy to clipboard operation
validate copied to clipboard

Turn `validate::violation`s into conditions

Open iqis opened this issue 2 years ago • 1 comments

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
})

iqis avatar Nov 09 '22 20:11 iqis

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")

markvanderloo avatar Nov 14 '22 22:11 markvanderloo