cakephp/validation
Lightweight validation library from the CakePHP ecosystem. Define rules and validators for arrays and data objects, run checks, and collect readable error messages. Useful standalone or within CakePHP apps for consistent input validation.
The validation library in CakePHP provides features to build validators that can validate arbitrary arrays of data with ease.
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.
}
Please make sure you check the official documentation
How can I help you explore Laravel packages today?