cakephp/validation

CakePHP Validation library

Maintainers

👁 cakephp

Package info

github.com/cakephp/validation

Homepage

Issues

Forum

pkg:composer/cakephp/validation

Statistics

Installs: 523 628

Dependents: 15

Suggesters: 0

Stars: 42

5.4.0-RC1 2026-03-17 15:01 UTC

Requires

Requires (Dev)

Suggests

  • cakephp/i18n: If you want to use Validation::localizedTime()

Provides

None

Conflicts

None

Replaces

None

MIT f154879616a8f54762566c0b7ca508da2ad5b898

validationcakephpdata validation

This package is auto-updated.

Last update: 2026-06-08 04:46:44 UTC


README

👁 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')
 ->notEmptyString('name', 'We need your name.')
 ->requirePresence('comment')
 ->notEmptyString('comment', 'You need to give a comment.');

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

Documentation

Please make sure you check the official documentation