ember-validations icon indicating copy to clipboard operation
ember-validations copied to clipboard

Support to return upon first error

Open vecsuresh opened this issue 11 years ago • 6 comments

Would it be possible to exit validation execution upon first error instead of executing all the registered validations of an attribute, as in some scenarios it is not required to show all the messages of an attribute in one go like scenarios where error messages are displayed next to the input control inline, please correct me if this kind of support is already present and your contribution to this framework is very much appreciated.

vecsuresh avatar Mar 05 '13 11:03 vecsuresh

I understand the idea, but I wonder why do you want this feature. If you just wants to show only one message, you could use user.get('validationErrors.age.messages.firstObject'), it will then return the first error message, and you do not have to care about the others.

lcoq avatar Mar 05 '13 13:03 lcoq

age: {
                    presence: true,
                    numericality: {
                        moreThanOrEqualTo: 21,
                        lessThan: 99
                    }
       }

Lets consider a scenario where all the form errors are displayed in a common summary container by using 'validationErrors.fullMessages' helper, in the above example age has got presence and number validations and it displays both the errors in one go and my requirement is not to show the numericality errors until presence validator succeeds, is there any possibility to achieve this in the current framework?

vecsuresh avatar Mar 06 '13 05:03 vecsuresh

Sorry to respond so late, I am currently really busy.

Indeed, the library does not allow to do this kind of things easily. I'll try to think about its implementation soon.

lcoq avatar Mar 29 '13 16:03 lcoq

You can try https://github.com/kelonye/ember-validate which fails fast.

ghost avatar Mar 29 '13 16:03 ghost

If you're using ember-data, you could also take a look at https://github.com/dockyard/ember-validations which seems pretty good.

lcoq avatar Mar 29 '13 16:03 lcoq

Thanks for your valuable response and will update you if I can make any progress in this direction.

vecsuresh avatar Apr 01 '13 05:04 vecsuresh