all() passes validation even when a rule throws an error
Hi, thanks for the great package! It really helps a lot.
I’ve been using the all() and any() validation functions and encountered some unexpected behavior:
When one of the rules inside the confrontation object throws an error (e.g., due to missing column), the overall validation still passes. I would expect that in such cases, the validation should fail, since an error likely means something went wrong with the check.
val <- validator(a >0)
out <- confront(women, val)
all(out)
# TRUE
Would love to know if this is intentional — and if not, whether you'd consider changing the behavior so that errors within rules cause the overall validation to fail.
Thanks again!
All statements about the empty set are true. So I think formally this is correct behavior, even though it is maybe counterintuitive
You can set the raise option to ensure that confront crashes on a failing rule.
Thanks for your reply, and sorry for my late response.
I’m not looking to make confront() crash — I’d just like to use the validation result in an if clause and be able to tell if any of the rules failed or errored. Right now, the all() function can return TRUE even if some rules failed to evaluate, which is a bit misleading in that context.
If the default behavior will not be changed, another argument can be included that checks returns FALSE for an error validation? all and any have already the na.rm argument, so maybe something similar like fail_on_error or error.rm can be included. I will try to make PR for that to see if that is acceptable.