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

What's the internal difference between Phalcon\Validation and Phalcon\Mvc\Model\Validator?

I get that Phalcon\Validation is used for forms and Phalcon\Mvc\Model\Validator for models, but what's the main reason for the separation? I was looking at the source code and it seems to have some sort of duplication of functionality.

I guess it would be too complex to keep a common interface? But what if I want to create a custom validator and use it both in the Model or any sort of input?



17.5k

My understanding is that Model\Validator is restricted for use within a model and that model's CRUD methods and Phalcon\Validation can be invoked independently (outside of a model) and used at anytime.



16.0k
Accepted
answer

exactly as @Zach said, but with Phalcon 2.1 "Phalcon\Mvc\Model\Validator" is deprecated and replaced with "Phalcon\Validation"; so is one validator for all



32.2k

Thanks for pointing me to the right direction! An kudos to Phalcon!