We have moved our forum to GitHub Discussions. For questions about Phalcon v3/v4/v5 you can visit here and for Phalcon v6 here.

Why stop the model validation when standard PresenceOf/ConstraintViolation validation failed?

Hi.

I think Phalcon's model validation flow is like this: (v1.3.2)

  1. standard ConstraintViolation(FK) validation (Virtual Foreign Keys Working with Models — Phalcon 2.0.0 documentation)
  2. standard PresenceOf(NotNull) validation
  3. user defined validation(validation() method in model class)

1. standard ConstraintViolation(FK) validation

  • If one of the ConstraintViolation validation invalid, other ConstraintViolation will never process.
  • And validation will finish.

2. standard PresenceOf(NotNull) validation

  • If one of the PresenceOf validation invalid, other PresenceOf validation will process.
  • But If one or more invalids found, validation will finish.

3. user defined validation(validation() method in model class)

  • From the above, user defined validation is process only when ConstraintViolation validations and PresenceOf validations are all valid.

So, why stop validation at 1. and 2? Can I change this behavior? I hope continue to all validation process.

Similar discussion

Thanks.



33.8k

Why you will keep going validating something that, from the very first time, isn't valid to proccess?

I think user want to know all validation result at once.



5.9k
Accepted
answer

Sorry, I'll show example code at another thread. So close this thread.

Thanks.