%PDF- %GIF98; %PNG;
Server : ApacheSystem : Linux host.digitalbabaji.in 4.18.0-513.11.1.el8_9.x86_64 #1 SMP Wed Jan 17 02:00:40 EST 2024 x86_64 User : addictionfreeind ( 1003) PHP Version : 7.2.34 Disable Function : exec,passthru,shell_exec,system Directory : /home/addictionfreeind/public_html/vendor/cakephp/cakephp/src/Validation/ |
Upload File : |
[](https://packagist.org/packages/cakephp/validation)
[](LICENSE.txt)
# 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:
```php
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](https://book.cakephp.org/3.0/en/core-libraries/validation.html)