https://github.com/joylei/php-validation
Another fluent validation library for php
https://github.com/joylei/php-validation
fluentvalidation php-library validation
Last synced: 9 months ago
JSON representation
Another fluent validation library for php
- Host: GitHub
- URL: https://github.com/joylei/php-validation
- Owner: Joylei
- License: mit
- Created: 2017-04-24T09:37:16.000Z (over 8 years ago)
- Default Branch: master
- Last Pushed: 2017-04-24T10:02:38.000Z (over 8 years ago)
- Last Synced: 2025-02-06T06:44:22.269Z (11 months ago)
- Topics: fluentvalidation, php-library, validation
- Language: PHP
- Size: 11.7 KB
- Stars: 2
- Watchers: 3
- Forks: 0
- Open Issues: 0
-
Metadata Files:
- Readme: README.md
- License: LICENSE
Awesome Lists containing this project
README
# PHP-Validation
Another fluent validation library for php
## Usage
```php
$validator = new Validator();
$validator->ruleFor('field1',function(){
$this->isRequired('required');
$this->isNumber('is number');
})->end()->ruleFor('field2', function(){
$this->hasRange(5, 10, 'range(5,10)');
});
$result = $validator->validate([
'field1' => 'aaa',
'field2' => '20'
]);
echo $result->hasError();
echo $result->getError();
```
For more information, please see tests in the source code.
## License
MIT