Hi @sekmo, and thanks for the question! You’ve explained yourself well, I totally understand what you’re looking to do.
In fact, what you’re looking to do here sounds a lot like dry-schema’s hints extension:
In addition to error messages, you can also access hints, which are generated from your rules. While
errors
tell you which predicate checks failed,hints
tell you which additional predicate checks were not evaluated because an earlier predicate failed.
However, this is a little trickier to achieve within dry-validation rules, because unlike dry-schema predicates, which are defined more as “data”—just as predicate names and options—dry-validation rules are instead defined by arbitrary Ruby code. The reason that Ruby code doesn’t execute if their dependent keys are not valid is because that Ruby code may actually crash if those values are not in their expected states.
So all of this is to say: right now, what you’re looking to achieve isn’t something that dry-validation offers, for the reason above.
Of course, you (or someone else) would certainly be welcome to explore introducing this feature. Doing this well would come down to figuring out an approach for extracting the potential error messages from rule methods while still maintaining a straightforward and streamlined developer experience for actually writing those rule methods.
I’ll just cc @flash-gordon and @solnic in case they have any other thoughts to add here.