vex icon indicating copy to clipboard operation
vex copied to clipboard

Dependent validators

Open stevegraham opened this issue 10 years ago • 0 comments

I'm currently using Vex.Struct to build form models in my Phoenix application. The library is extremely useful, thanks for releasing it. One thing I'd like to do is dependent validations, i.e. validations that depend on some other field in the struct. Currently this is not possible as Vex passes only the value of the field under test into the validate function. It would be cool if it worked in a similar way ActiveModel::EachValidator in Rails, i.e. the validation receives the entire struct as context as well as the value under test. This would also have the benefit of enabling the confirmation validator without Vex.extract/3 treating it as a special case.

I intend to contribute a patch myself, but first I want to get your thoughts on the best approach, backwards compatibility considerations re the existing Vex.Validator.Behaviour, etc.

What do you think?

stevegraham avatar Sep 11 '15 18:09 stevegraham