almendra / validators
A simple type validator.
Installs: 67
Dependents: 1
Suggesters: 0
Security: 0
Stars: 1
Watchers: 1
Forks: 0
pkg:composer/almendra/validators
Requires (Dev)
- phpunit/phpunit: 5.4.6
This package is not auto-updated.
Last update: 2025-10-02 00:26:23 UTC
README
Installation
Through composer:
composer require almendra/validators
How to use it
-
- Stand alone
$validator = new Validator();
$result = $validator
-> integer(10)
-> min(3)
-> max(20)
-> validate();
-
- Within a controller
# SomeController extends Http\Controller or implements Http\Interfaces\ControllerInterface
$controller = new SomeController;
$controller -> validate(function($request, $validator) {
$result = $validator
-> string($request -> get('name'))
-> min(3)
-> max(20)
-> validate();
return $result;
});
It can also be used with a type homogeneus array:
$validator = new Validator();
$result = $validator
-> string($request -> all())
-> range(1, 255)
-> validate();
Support
Currently, the validator supports the following types: integer, string, double, float, file