Florian Krämer fe4f1f45b7 Adding a custom error message to Validator::allowEmpty() 10 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 72f5332146 Make all doc block classes FQCN as per CS. 10 years ago
ValidatableInterface.php be845a3a01 Run phpcbf for PSR2 CS fixers 11 years ago
Validation.php 59b9f4cc86 Merge pull request #8726 from cakephp/validate-numelements 10 years ago
ValidationRule.php 2c5384153b Code Cleanup - InvalidArgumentException 11 years ago
ValidationSet.php c8d3974a48 Always import classes. 10 years ago
Validator.php fe4f1f45b7 Adding a custom error message to Validator::allowEmpty() 10 years ago
ValidatorAwareTrait.php a2318a3bec Run sniffer to auto-fix default params into doc blocks. 10 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