Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Turn validate::violations into conditions #170

Open
iqis opened this issue Nov 9, 2022 · 1 comment
Open

Turn validate::violations into conditions #170

iqis opened this issue Nov 9, 2022 · 1 comment
Labels

Comments

@iqis
Copy link

iqis commented Nov 9, 2022

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
})
@markvanderloo
Copy link
Member

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

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Projects
None yet
Development

No branches or pull requests

2 participants