Download the PHP package terminusstudio/phpvalidator without Composer
On this page you can find all versions of the php package terminusstudio/phpvalidator. It is possible to download/install these versions without Composer. Possible dependencies are resolved automatically.
Download terminusstudio/phpvalidator
More information about terminusstudio/phpvalidator
Files in terminusstudio/phpvalidator
Package phpvalidator
Short Description A PHP validator using respect validator. Built for Slim.
License MIT
Homepage https://github.com/TerminusStudio/PHPValidator
Informations about the package phpvalidator
Slim PHP Respect Validation
A SlimPHP validator using respect validation package.
Install
Via Composer
Usage
Initializing
Configuration
useSession
- If set to true, validation results are saved in a session variable that can be accessed in the next request (using the ValidatorMiddleware). Defaults to false.
Using a container
Without container
Example Usage
Middleware
The ValidatorMiddleware can be added to slim if you set the useSession to true in $config.
If there were any errors, the next request will have access to the errors and values. To enable the middleware just add ValidatorMiddleware
class to the Slim app and pass the validator instance.
Twig Extension
This plugin also supports Twig functions. To enable just add ValidatorTwig
when initializing twig. This requires slim/twig-view
package.
There are currently 5 functions supported by the extension,
has_errors()
- Returns true if there are any errorshas_error($key)
- Returns true if$key
is invalidget_errors()
- Returns an array containing all errorsget_error($key, $toString = true)
- Returns an array containing all errors for a specific$key
. If$toString
is set to true, then it returns a string.get_value($key, $default = null)
- Returns the value for a specific$key
.
$key
is the field name set in the request.
License
The MIT License (MIT). Please see License File for more information.
All versions of phpvalidator with dependencies
psr/http-message Version ^1.0
psr/http-server-handler Version ^1.0
respect/validation Version 2.0.17