memcrab / validator
Additional static layer for respect validator
Installs: 512
Dependents: 0
Suggesters: 0
Security: 0
Stars: 0
Watchers: 3
Forks: 0
Open Issues: 0
Type:package
Requires
- php: >=7.4
- psr/log: ^1.0
- respect/validation: ^2.1
Requires (Dev)
- phpunit/phpunit: 6.*.*
README
Install
composer require memcrab/validator
Dependencies
- psr/log: "^1.0"
- respect/validation: "^2.1"
Usage
use Memcrab\Validator\Validator; use Respect\Validation\Validator as v; class Auth extends Validator { public function authorization() { $this ->addBodyRule('email', v::email(), 'Email not valid', 400101) ->addBodyRule('password', v::length(8, 100), 'Password should be more than 8 symbols', 400102); } }
<?php declare (strict_types = 1); require_once __DIR__ . "/vendor/autoload.php"; use Memcrab\Validator\Validator; use Memcrab\Validator\ValidatorException; try { // ... getting request GET($getParramethers) and POST($postParramethers) ... $Validator = new Auth($getParramethers, $postParramethers); $Validator->authorization(); $Validator->validate(); } catch (ValidatorException $error) { // handle validation error }
MIT Licensed