Download the PHP package nelson-dominici/slimgry without Composer
On this page you can find all versions of the php package nelson-dominici/slimgry. It is possible to download/install these versions without Composer. Possible dependencies are resolved automatically.
Table of contents
Download nelson-dominici/slimgry
More information about nelson-dominici/slimgry
Files in nelson-dominici/slimgry
Download nelson-dominici/slimgry
More information about nelson-dominici/slimgry
Files in nelson-dominici/slimgry
Vendor nelson-dominici
Package slimgry
Short Description A powerful validation middleware for the slim framework
License MIT
Package slimgry
Short Description A powerful validation middleware for the slim framework
License MIT
Please rate this library. Is it a good library?
Informations about the package slimgry
Slimgry is a validation middleware for the Slim framework, which validates the request body, with validation syntax similar to Laravel.
Install
Usage
To add validations to a route, add the NelsonDominici\Slimgry\Slimgry middleware with the validations in the constructor.
If any validation method fails, an NelsonDominici\Slimgry\Exceptions\ValidationMethodException exception will be thrown.
You can also use |.
Validating nested fields
You can use "dot notation" to validate nested fields, example:
Adding custom message when validation method fails
Add a second array in the Slimgry class to store custom messages, choose which field the message refers to along with a "dot" and the validation method that failed.
Validation Methods List
| Validation Method | Function | Attention! |
|---|---|---|
| array | The field under validation must be a PHP array |
|
| boolean | The field under validation must be a boolean |
Only true or false is accepted |
The field under validation must be a valid email |
filter_var() is used with FILTER_VALIDATE_EMAIL |
|
| gt:value | The field under validation must be greater than a numeric value |
Only numeric values are validated |
| gte:value | The field under validation must be greater than or equal to a numeric value |
Only numeric values are validated |
| integer | The field under validation must be an integer |
|
| ip | The field under validation must be an IP address | filter_var() is used with FILTER_VALIDATE_IP |
| max:value | The field under validation must have a maximum number of elements |
Only arrays, strings, and numeric values are validated |
| min:value | The field under validation must have a minimum number of elements |
Only arrays, strings, and numeric values are validated |
| nullable | The field under validation may be null |
|
| numeric | The field under validation must be numeric |
|
| present | The field under validation must exist in request body | |
| regex:pattern | The field under validation must match the given regular expression | |
| required | The field under validation must be present in request body and not "empty" | Values considered "empty" are null, empty string and empty array |
| size:value | The field under validation must have a specific number of elements |
Only arrays, strings, and numeric values are validated |
| string | The field under validation must be a string |
|
| trim | Remove white space from The field under validation | |
| uuid | The field under validation must be a valid universally unique identifier (UUID) in 4 version |
All versions of slimgry with dependencies
PHP Build Version
Package Version
The package nelson-dominici/slimgry contains the following files
Loading the files please wait ...