ansman / validate.js

A declarative validation library written javascript
https://validatejs.org
MIT License
2.63k stars 336 forks source link

Compare with other "field" #109

Closed matthijn closed 6 years ago

matthijn commented 8 years ago

Is it possible to compare with another field? There are two places where this could be useful:

Comparing "repeating password / email fields" or comparing dates (e.g one should be before another date). I'd say these are both fairly common in form handling. But I can't seem to figure out how to to either of these.

edit: It seems I can create a custom validator, and use an option to set the field to compare it to. And get that value from the attributes object.

ansman commented 8 years ago

You can validate that two fields are equal but that's it for now: http://validatejs.org/#validators-equality

If you want something more advanced you'd have to write your own validator.

bayarja commented 7 years ago

but when single value validation. it's not possible. right?

ansman commented 6 years ago

No, how would that even work?