Download the PHP package inok/slim-validation4 without Composer
On this page you can find all versions of the php package inok/slim-validation4. It is possible to download/install these versions without Composer. Possible dependencies are resolved automatically.
Download inok/slim-validation4
More information about inok/slim-validation4
Files in inok/slim-validation4
Package slim-validation4
Short Description A slim middleware for validation based on Respect/Validation
License GPL-2.0+
Informations about the package slim-validation4
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 Inok\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-validation4 with dependencies
psr/http-message Version ^1.0
psr/http-factory Version ^1.0
slim/slim Version 4.*
respect/validation Version ^2.2.3
ext-simplexml Version *