Florian Krämer 86e6a8071c Adding support for UploadedFileInterface to imageSize() 9 years ago
..
LICENSE.txt 06052c3a15 Adds license file and badges for Validation subtree split 10 years ago
README.md 06052c3a15 Adds license file and badges for Validation subtree split 10 years ago
RulesProvider.php 855c4d114b Fix CS error. 9 years ago
ValidatableInterface.php be845a3a01 Run phpcbf for PSR2 CS fixers 11 years ago
Validation.php 86e6a8071c Adding support for UploadedFileInterface to imageSize() 9 years ago
ValidationRule.php 855c4d114b Fix CS error. 9 years ago
ValidationSet.php 855c4d114b Fix CS error. 9 years ago
Validator.php 6f7689b967 Merge branch 'master' into 3.next 9 years ago
ValidatorAwareTrait.php 855c4d114b Fix CS error. 9 years ago
composer.json 6a7a01fe4a Declare splits as stable. 10 years ago

README.md

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.

Usage

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();
$validator
    ->requirePresence('email')
    ->add('email', 'validFormat', [
        'rule' => 'email',
        'message' => 'E-mail must be valid'
    ])
    ->requirePresence('name')
    ->notEmpty('name', 'We need your name.')
    ->requirePresence('comment')
    ->notEmpty('comment', 'You need to give a comment.');

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

Documentation

Please make sure you check the official documentation