PHPackages                             nayzo/json-schema-validator-bundle - PHPackages - PHPackages  [Skip to content](#main-content)[PHPackages](/)[Directory](/)[Categories](/categories)[Trending](/trending)[Leaderboard](/leaderboard)[Changelog](/changelog)[Analyze](/analyze)[Collections](/collections)[Log in](/login)[Sign up](/register)

1. [Directory](/)
2. /
3. [HTTP &amp; Networking](/categories/http)
4. /
5. nayzo/json-schema-validator-bundle

ActiveSymfony-bundle[HTTP &amp; Networking](/categories/http)

nayzo/json-schema-validator-bundle
==================================

Symfony bundle used to handle Json Schema validation for PSR7 &amp; PSR17

v1.0.1(4mo ago)10MITPHPPHP &gt;=8.1CI passing

Since Feb 17Pushed 4mo ago1 watchersCompare

[ Source](https://github.com/nayzo/json-schema-validator-bundle)[ Packagist](https://packagist.org/packages/nayzo/json-schema-validator-bundle)[ RSS](/packages/nayzo-json-schema-validator-bundle/feed)WikiDiscussions main Synced today

READMEChangelog (2)Dependencies (9)Versions (3)Used By (0)

JsonSchemaValidatorBundle
=========================

[](#jsonschemavalidatorbundle)

[![tests](https://github.com/nayzo/json-schema-validator-bundle/actions/workflows/tests.yaml/badge.svg)](https://github.com/nayzo/json-schema-validator-bundle/actions/workflows/tests.yaml)[![Latest Stable Version](https://camo.githubusercontent.com/e7852ae03374132b5f6c193f409afcd48f93bb1e1431edde8db89830625d4bfe/68747470733a2f2f706f7365722e707567782e6f72672f6e61797a6f2f6a736f6e2d736368656d612d76616c696461746f722d62756e646c652f762f737461626c65)](https://packagist.org/packages/nayzo/json-schema-validator-bundle)

The **JsonSchemaValidatorBundle** is a Symfony bundle that validate request payload and response with Json Schema for PSR7 &amp; PSR17.

###### This Bundle is compatible with **Symfony &gt;= 5.0**

[](#this-bundle-is-compatible-with-symfony--50)

Installation
------------

[](#installation)

Install the bundle:

```
$ composer require nayzo/json-schema-validator-bundle

```

Usage
-----

[](#usage)

#### Configuration:

[](#configuration)

```
# config/packages/nayzo_json_schema_validator.yaml
nayzo_json_schema_validator:
    resources:
        my_account:
            contract_file_path: '%kernel.project_dir%/resources/api_contract/myaccount1.yaml'
            enable_default_request_validation_subscriber: true  # default to false
            enable_default_response_validation_subscriber: true # default to false

        my_second_account:
            contract_file_path: '%kernel.project_dir%/resources/api_contract/myaccount2.yaml'

    enable_default_validation_exception_subscriber: true  # default to false. (if activated, the default validation exception subscriber will be triggered and executed).
    validation_exception_status_code: 400 # default to 422
```

#### Define the Validation Support (mandatory):

[](#define-the-validation-support-mandatory)

Note that if no validation support is found (exp: `MyAccountValidationSupport`), no request/response validation subscriber will be triggered or executed.

```
