Download the PHP package blackbear/validation without Composer
On this page you can find all versions of the php package blackbear/validation. It is possible to download/install these versions without Composer. Possible dependencies are resolved automatically.
Table of contents
Download blackbear/validation
More information about blackbear/validation
Files in blackbear/validation
Download blackbear/validation
More information about blackbear/validation
Files in blackbear/validation
Vendor blackbear
Package validation
Short Description validation data
License MIT
Package validation
Short Description validation data
License MIT
Keywords validation
Please rate this library. Is it a good library?
Informations about the package validation
Class Validation for php
Validator
Validate input value
Installation
composer require blackbear/validation
Example
$data = [
'age' => 20,
'email' => '[email protected]'
];
$rules = [
'age' => 'required',
'email' => 'email|required'
];
$messages = [
'age.required' => 'Please fill age',
'email.email' => 'Please fill email'
];
$validator = new Validator($data, $rules, $messages);
if ($validator->passes()) {
echo 'Validate successful';
} else {
echo 'Validate fails'
}
Get error messages
$errors = $validator->getErrors();
Add custom rule
$validator->addExtension('bigger', function($attribue, $value) {
return $value > $attribue[0];
});
$data = [
'age' => 20,
'email' => '[email protected]'
];
$rules = [
'age' => 'required|bigger:18',
'email' => 'email|required'
];
$messages = [
'age.required' => 'Please fill age',
'email.email' => 'Please fill email'
];
$validator = new Validator();
$validator->setData($data)
->setRules($rules)
->setMessages($messages);
if ($validator->passes()) {
echo 'Validate successful';
} else {
echo 'Validate fails'
}
Public method
setData(array $data)
setRules(array $rules)
setMessages(array $messages)
passes()
fails()
Default rules
required
email
exception
ip
min: min:20
max: max:20
in_array: in_array:1,2,3
not_in_array: not_in_array:1,2,3
between: between:10,100
regex: regexp:/^([\d]+)$/
url
int
float
double
boolean
nullable
equals: equals:8
All versions of validation with dependencies
PHP Build Version
Package Version
No informations.
The package blackbear/validation contains the following files
Loading the files please wait ...