Ecosyste.ms: Awesome

An open API service indexing awesome lists of open source software.

Awesome Lists | Featured Topics | Projects

https://github.com/memcrab/validator

PHP Validator Based on Another Validator
https://github.com/memcrab/validator

Last synced: about 2 months ago
JSON representation

PHP Validator Based on Another Validator

Awesome Lists containing this project

README

        

PHP Validator as Composer Library
==========================

Install
--------
```composer require memcrab/validator```

Dependencies
--------
```
- psr/log: "^1.0"
- respect/validation: "^2.1"
```

Usage
--------
```php
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
authorization();
$Validator->validate();

} catch (ValidatorException $error) {
// handle validation error
}

```

---
**MIT Licensed**