Ignore other validators if one fails

Hey guys,

I'm sure I've seen this somewhere before, but I just can't find the topic again.

Let's say I create form like in here: http://docs.phalconphp.com/en/latest/reference/forms.html#validation and add 2 validators to my name field. Currently, when field is empty they both seem to fire and I end up with stupid error messages 'Name is required' 'Name must be longer than 6' and so on.

Is is possible to ignore remaining form validators if one of them fails? So only one message is generated per field?


edit Just found this: https://github.com/phalcon/cphalcon/issues/1540 so I guess it's not possible at the moment.


there is option to stop the validation of validator fails, read here: http://docs.phalconphp.com/en/latest/reference/validation.html#cancelling-validations but I didnt get around to actualy do anything with that so dont know if by "chain" in documentation they mean all validators or just the validators with same id

You could test it :)

Also you could make your own validator for your field so you could just put some conditions in your validator to do stuff you need and eventualy stop if problem is found. Which would then jump on next validator for next field.


Ha, I knew I've seen it somewhere. That's exactly it, thanks!