Ecosyste.ms: Awesome
An open API service indexing awesome lists of open source software.
https://github.com/cakephp/validation
[READ-ONLY] Validation library from CakePHP. This repo is a split of the main code that can be found in https://github.com/cakephp/cakephp
https://github.com/cakephp/validation
Last synced: about 1 month ago
JSON representation
[READ-ONLY] Validation library from CakePHP. This repo is a split of the main code that can be found in https://github.com/cakephp/cakephp
- Host: GitHub
- URL: https://github.com/cakephp/validation
- Owner: cakephp
- License: other
- Created: 2014-08-26T09:27:04.000Z (over 10 years ago)
- Default Branch: master
- Last Pushed: 2024-10-04T02:57:17.000Z (2 months ago)
- Last Synced: 2024-10-31T07:34:50.116Z (about 1 month ago)
- Language: PHP
- Homepage:
- Size: 771 KB
- Stars: 43
- Watchers: 29
- Forks: 12
- Open Issues: 0
-
Metadata Files:
- Readme: README.md
- License: LICENSE.txt
Awesome Lists containing this project
- awesome-php - CakePHP Validation - Another validation library. (Table of Contents / Filtering and Validation)
- awesome-php-cn - CakePHP Validation - 另一个验证库. (目录 / 过滤和验证 Filtering and Validation)
- awesome-projects - CakePHP Validation - Another validation library. (PHP / Filtering and Validation)
- awesome-php - CakePHP Validation - Another validation library. (Table of Contents / Filtering, Sanitizing and Validation)
README
[![Total Downloads](https://img.shields.io/packagist/dt/cakephp/validation.svg?style=flat-square)](https://packagist.org/packages/cakephp/validation)
[![License](https://img.shields.io/badge/license-MIT-blue.svg?style=flat-square)](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')
->notEmptyString('name', 'We need your name.')
->requirePresence('comment')
->notEmptyString('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](https://book.cakephp.org/4/en/core-libraries/validation.html)