vivin / regula

Regula: An annotation-based form-validation framework in Javascript
126 stars 24 forks source link

Feature Request: Or constraints #15

Open troyji opened 13 years ago

troyji commented 13 years ago

It would be nice to have the ability to 'Or' constraints.

Use Case: I have an input field that can be blank. If it is not blank, it should be an integer.

Potential Solution:

<input type='text' data-constraints='@Blank | @Integer @Min(value=0)'/>
vivin commented 13 years ago

Currently this can be accomplished with a custom constraint. This is definitely a cool feature and I'd like to implement something like this at some point in the future. It would require changing the parser and also the way validation is performed. Currently each constraint is validated independently.