validate.js icon indicating copy to clipboard operation
validate.js copied to clipboard

Stop validation at first break

Open baidario opened this issue 7 years ago • 3 comments
trafficstars

When a field has a few rules, library check all rules even if first failed. For example, password has 2 rules: length and pattern validation image And if length invalid I don't want to check pattern validity. Is such option exists or it should be added?

baidario avatar Jun 20 '18 19:06 baidario

Similarly, if it fails "presence", there is no point in checking for any others. Current workaround that I see is that you just print the first error in the array that is returned

eleow avatar Aug 10 '18 02:08 eleow

@eleow , sometimes it is not enough though. :(

My case includes an async validation (checking for uniqueness of an email address) and even if I could display only the first error - I still have a round-trip query.

bohdan-shulha avatar Jan 25 '19 13:01 bohdan-shulha

@ansman I am ready to take this in case it has chances to be merged.

bohdan-shulha avatar Jan 25 '19 14:01 bohdan-shulha