mrjulio / rapture-validation
Rapture validation component
v1.0.2
2017-11-18 21:00 UTC
Requires
- php: >=5.4.0
This package is not auto-updated.
Last update: 2024-11-02 16:36:24 UTC
README
Simple validation for PHP.
Requirements
- PHP v5.4.0
- php-date, php-filter, php-json, php-mbstring, php-pcre
Install
composer require mrjulio/rapture-validation
Quick Start
$validator = new Email(); $validator->isValid('test@gmail.com'); // true $validator->isValid('test[at]gmail.com'); // false $validator = new Country(Country::ISO2); $validator->isValid('us'); // true $validator->isValid('ux'); // false // Group Validator $validator = new Group([ 'email' => [ ['required'], ['email', null, 'Invalid email format :value'], ], 'age' => [ ['optional'], ['number', null, 'Invalid age'], ['between', [13, 60], 'You have to be at least :min years old!'], ], 'country' => [ ['country', [Country::ISO3], 'Invalid ISO3 for country ":value"'], ] ]); $validator->isValid([ 'email' => 'test@gmail.com', 'age' => 1, 'country' => 'xxx' ]); // false $validator->getFirstError(); // Invalid ISO3 for country "xxx"
List of validators
About
Author
Iulian N. rapture@iuliann.ro
Testing
cd ./test && phpunit
License
Rapture PHP Validation is licensed under the MIT License - see the LICENSE
file for details.