Skip to content

Dependent validators  #15

@stevegraham

Description

@stevegraham

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?

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions