Download the PHP package laraantunes/validare without Composer
On this page you can find all versions of the php package laraantunes/validare. It is possible to download/install these versions without Composer. Possible dependencies are resolved automatically.
Download laraantunes/validare
More information about laraantunes/validare
Files in laraantunes/validare
Package validare
Short Description A simple-to-use validation library.
License GPL-3.0-or-later
Informations about the package validare
Validare
A simple to use validation library.
Installation
composer require laraantunes/validare
Basic Usage
Create a class and use the \Validare\Bind
trait and add the rules by the validate() method:
The validate() method
The valid()
method is an alias for validate()
, without any parameter. This way, it'll run the validation for the object.
If validate()
is called with parameters, it'll add a validation for the field passed as the first parameter with the rules passed as the other parameters:
The default Rules
Validare comes with many default useful rules and more still will come. All them are valid as constants of the \Validare\Rule
class:
- REQUIRED
- POSITIVE
- NEGATIVE
- LENGTH
- MIN_LENGTH
- MAX_LENGTH
- MORE
- LESS
- MORE_OR_EQUALS
- LESS_OR_EQUALS
- EQUALS
- NOT_EQUALS
- IS_ARRAY
- IS_STRING
- IS_NUMERIC
- IS_A
- COUNT_EQUALS
- COUNT_MORE
- COUNT_LESS
- COUNT_MORE_EQUALS
- COUNT_LESS_EQUALS
- HAS_ATTRIBUTE
- HAS_ATTRIBUTE_VALUE
The Assert class
If you need to validate a specific value, you may use the \Validare\Assert
class. It has 2 basic methods, a magic method that calls the default rules dynamically and a value()
method that validates something with the same syntax that the Validare\Bind::validate()
method:
Tests
Tests are under test/
folder using PHPUnit.
Contributing
Fell free to create pull requests with new rules, bug fixing and suggestions! <3