Skip to content

Commit

Permalink
Merge pull request #4392 from cakephp/3.0-validation-subtree
Browse files Browse the repository at this point in the history
Adding the required changes to to a subtree split of the validation library
  • Loading branch information
markstory committed Aug 26, 2014
2 parents 55cf771 + 2258436 commit fd505ce
Show file tree
Hide file tree
Showing 3 changed files with 53 additions and 1 deletion.
3 changes: 2 additions & 1 deletion composer.json
Expand Up @@ -41,6 +41,7 @@
},
"replace": {
"cakephp/collection": "self.version",
"cakephp/event": "self.version"
"cakephp/event": "self.version",
"cakephp/validation": "self.version"
}
}
34 changes: 34 additions & 0 deletions src/Validation/README.md
@@ -0,0 +1,34 @@
# 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
->validatePresence('email')
->add('email', 'validFormat', [
'rule' => 'email',
'message' => 'E-mail must be valid'
])
->validatePresence('name')
->notEmpty('name', 'We need your name.')
->validatePresence('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](http://book.cakephp.org/3.0/en/core-libraries/validation.html)
17 changes: 17 additions & 0 deletions src/Validation/composer.json
@@ -0,0 +1,17 @@
{
"name": "cakephp/validation",
"description": "CakePHP Validation library",
"license": "MIT",
"authors": [
{
"name": "CakePHP Community",
"homepage": "http://cakephp.org"
}
],
"autoload": {
"psr-4": {
"Cake\\Validation\\": "."
}
},
"minimum-stability": "beta"
}

0 comments on commit fd505ce

Please sign in to comment.