mohammedalkutrani / validator
validate form-data
Installs: 7
Dependents: 0
Suggesters: 0
Security: 0
Stars: 6
Watchers: 2
Forks: 1
Open Issues: 0
pkg:composer/mohammedalkutrani/validator
Requires (Dev)
- phpunit/phpunit: ^8
- webmozart/assert: 1.6.0
This package is auto-updated.
Last update: 2025-10-05 19:46:11 UTC
README
It's a simple packge for validation the data before touch your database.
Core Features
- PSR-4 for autoloading.
- PSR-2 for coding style.
- Strategy Pattern for changing the rules in the runtime.
- Facade Pattern for make it esey to use.
- Implements your own rule.
- Test 100%.
Installation
composer require mohammedalkutrani/validator
Simple Usage
use Validator\Facade\Validation; use Validator\Rules; $v = Validation::make( [ // the given data. 'name' => 'mohammedalkutrani@gmail.com', 'age' => 25 ], [ // the rules for the data. 'name' => [Rules::NUMBER, Rules::MIN.'|4'], 'age' => [Rules::EMAIL] ] ); // check if it passed if(!$v->isPassed()) // it will return boolean { print_r($v->getMessages()); // getting the messages. }
The result
Array ( [name] => Array ( [0] => the name should be a number [1] => the name should shorter then 4 ) [age] => Array ( [0] => the age should be an email ) )