Mark Story 1961417d49 Merge pull request #14708 from cakephp/3.next-backports2 5 years ago
..
LICENSE.txt c61ab5ee95 Use HTTPS for the cakefoundation.org URL 8 years ago
README.md 4e308c3c6f Renamed Validator::errors() to Validator::validate() 6 years ago
RulesProvider.php 7c79b9e99c Backports from 4.next. 5 years ago
ValidatableInterface.php 2b40e56493 Fix newlines around psr2 6 years ago
Validation.php 7c79b9e99c Backports from 4.next. 5 years ago
ValidationRule.php 409fa5a241 Backport 4.next changes to 3.next 5 years ago
ValidationSet.php 409fa5a241 Backport 4.next changes to 3.next 5 years ago
Validator.php b1a49f67e5 Merge pull request #14682 from cakephp/3.next-validation 5 years ago
ValidatorAwareInterface.php 2b40e56493 Fix newlines around psr2 6 years ago
ValidatorAwareTrait.php 409fa5a241 Backport 4.next changes to 3.next 5 years ago
composer.json 8400540c75 Add missing core dependencies and bump versions. 8 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->validate($_POST);
if (!empty($errors)) {
    // display errors.
}

Documentation

Please make sure you check the official documentation