Mark Story 3866487a5b Merge branch 'master' into 3.next 9 years ago
..
LICENSE.txt 06052c3a15 Adds license file and badges for Validation subtree split 10 years ago
README.md fe1d812c89 Update URL in *.md, *.json 9 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 3866487a5b Merge branch 'master' into 3.next 9 years ago
ValidationRule.php eeb969d78b Removing default null property assignments. Class property default value is NULL if not specified; assigning it explicitly is redundant. 9 years ago
ValidationSet.php cd379b2fc5 Fix up doc block return types for chaining. 9 years ago
Validator.php 3faa0c269d Merge pull request #10303 from cleptric/issue-10107 9 years ago
ValidatorAwareTrait.php 7678f94a23 Remove deprecated calls in Cake\Validator and Cake\View 9 years ago
composer.json 9bd958e61c update composer 9 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