Solved thread

This post is marked as solved. If you think the information contained on this thread must be part of the official documentation, please contribute submitting a pull request to its repository.

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.



19.6k

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.



2.6k
Accepted
answer

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

Thanks.