Download the PHP package mrsuh/json-validation-bundle without Composer
On this page you can find all versions of the php package mrsuh/json-validation-bundle. It is possible to download/install these versions without Composer. Possible dependencies are resolved automatically.
Download mrsuh/json-validation-bundle
More information about mrsuh/json-validation-bundle
Files in mrsuh/json-validation-bundle
Package json-validation-bundle
Short Description This bundle provides a way to validate JSON in request/response against a schema
License MIT
Informations about the package json-validation-bundle
JSON Validation Bundle
A Symfony bundle that provides an annotation to validate request/response JSON against a schema.
Differences from joipolloi/json-validation-bundle
- added
response
validation - supporting Symfony
>=3.4
,4.*
,5.*
,6.*
- error/warnings logging
- single validator usage
Versions
- ^3 for Symfony
< 6.*
- ^4 for Symfony
>= 6.*
Installation
Usage
Create validation schemes
See json-schema for more details
JsonSchema/Request/myAction.json
JsonSchema/Response/myAction.json
Create controller with annotations ValidateJsonRequest
and/or ValidateJsonResponse
Specify $validJson
argument if you want get decoded JSON data from the request
Specify the array
type of the $validJson
argument if you want get decoded JSON data as array
Specify the object
type of the $validJson
argument or don't specify type if you want get decoded JSON data as object
Controller/MyController.php
Invalid JSON passed to request
If invalid JSON passed to request and config enable_request_listener
, enable_exception_listener
enabled
you get response as detailed in RFC7807 with header Content-Type:application/problem+json
and error
log entry
Invalid JSON passed to response
If invalid JSON passed to response and config enable_response_listener
enabled
you get warning
log entry
Configuration
Single validator usage
All versions of json-validation-bundle with dependencies
ext-json Version *
symfony/config Version >=3.0
symfony/http-foundation Version ^6.0
symfony/http-kernel Version ^6.0
symfony/dependency-injection Version ^6.0
justinrainbow/json-schema Version >=5.2
psr/log Version ^1.1
doctrine/annotations Version ^2.0