Download the PHP package davidepastore/slim-validation without Composer
On this page you can find all versions of the php package davidepastore/slim-validation. It is possible to download/install these versions without Composer. Possible dependencies are resolved automatically.
Download davidepastore/slim-validation
More information about davidepastore/slim-validation
Files in davidepastore/slim-validation
Package slim-validation
Short Description A slim middleware for validation based on Respect/Validation
License GPL-2.0+
Informations about the package slim-validation
Slim Framework Validation
A validation library for the Slim Framework. It internally uses Respect/Validation.
Table of contents
- Install
- Usage
- Register per route
- Register for all routes
- Route parameters
- JSON requests
- XML requests
- Translate errors
- Testing
- Contributing
- Credits
Install
Via Composer
Requires Slim 4.0.0 or newer.
Usage
In most cases you want to register DavidePastore\Slim\Validation
for a single route, however,
as it is middleware, you can also register it for all routes.
Register per route
Register for all routes
Route parameters
Note that requests parameters take priority over route parameters, so if you use the same name for a route and request parameter, the last will win and it will be considered for validation.
JSON requests
You can also validate a JSON request. Let's say your body request is:
and you want to validate the email.name
key. You can do it in this way:
If you'll have an error, the result would be:
XML requests
You can also validate a XML request. Let's say your body request is:
Let's say you have a POST request with a XML in its body:
and you want to validate the email.name
key. You can do it in this way:
If you'll have an error, the result would be:
Translate errors
You can provide a callable function to translate the errors.
Testing
Contributing
Please see CONTRIBUTING for details.
Credits
All versions of slim-validation with dependencies
psr/http-message Version ^1.0
respect/validation Version ^1.1 >=1.1.23
slim/http Version ^1.1
slim/psr7 Version ^0.3|^1.6