Datavalidation
Datavalidation is a very important component of an application that contains end user inputs.
It ensures that no malicious, weird or just plain wrong data reaches to the database, usually its also used to inform a user about what they did wrong so they can correctly enter their data.
Validation works by comparing the given data to certain ruleset and if it matches it can be persisted, if it doesn't match it will not persist and probably rollback the entire submit operation.
PHP itsself and CakePHP add alot of prepared functions that already implement that rule check.
In CakePHP you can simply use the validator that is called for its respective table when an entity is supposed to be saved, ontop of the validator you can call the individual rules per database column, for example
$validator ->integer('cancellation_deadline') ->notEmptyString('cancellation_deadline') ->requirePresence('cancellation_deadline') ->range('cancellation_deadline', CancellationDeadline::RANGE);
CakePHP already prepares the validation messages itsself, they do not need to, but can be set manually.
In CakePHP validation messages are displayed right under their respective form field (if there is a form).

