CakePHP Validation library

5.1.0-RC1 2024-05-20 03:35 UTC

This package is auto-updated.

Last update: 2024-05-21 02:50:47 UTC


Total Downloads License

CakePHP Validation Library

The validation library in CakePHP provides features to build validators that can validate arbitrary arrays of data with ease.


Validator objects define the rules that apply to a set of fields. Validator objects contain a mapping between fields and validation sets. Creating a validator is simple:

use Cake\Validation\Validator;

$validator = new Validator();
    ->add('email', 'validFormat', [
        'rule' => 'email',
        'message' => 'E-mail must be valid'
    ->notEmptyString('name', 'We need your name.')
    ->notEmptyString('comment', 'You need to give a comment.');

$errors = $validator->validate($_POST);
if (!empty($errors)) {
    // display errors.


Please make sure you check the official documentation