cakephp/cakephp — pull request #2340 by lorenzo (2013-11-17 13:52:26+00:00)
Title: 3.0 validation

This is a major refactor for the validation system and implements validation when saving, some of the highlights:

* New `Validation` namespace, the validation classes are generic enough to be used anywhere and are not coupled in any way to the ORM
* Moved the Validation class to the new namespace
* Removed much of the complexity in the old `ModelValidator` class, removed methods and some options as I think there were too many ways of doing the same thing.
* `ValidationSet` is no longer responsible for processing the validation for a field, it juts acts as container for multiple validation rules
* `validatePresence` and `allowEmpty` are now methods in the validator class
* Added ability to express validation rules using callable functions
* Added support to use a callable function in the 'on' key, this allows to do stuff like `'on' => function() { $entity->isAdminOwned(); }` for conditionally triggering validation rules
* Ability to have more than one validation set in the Table object, this has always been a popular request for CakePHP

Some questions I had:

* Field lists and validation: should the Validator class accept a fieldList too? I feel whatever case can be achieved with custom validator objects.
* Should we have a specific method for removing validation errors from the entity?