PHPackages                             basilicom/json-schema-request-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. [Validation &amp; Sanitization](/categories/validation)
4. /
5. basilicom/json-schema-request-validator-bundle

ActiveSymfony-bundle[Validation &amp; Sanitization](/categories/validation)

basilicom/json-schema-request-validator-bundle
==============================================

Easily validate Symfony request bodies via JSON schema and automatically reject invalid requests

v3.0.0(1y ago)15.0k↓50%MITPHPPHP ^8.2

Since Jan 12Pushed 1y ago10 watchersCompare

[ Source](https://github.com/basilicom/json-schema-request-validator-bundle)[ Packagist](https://packagist.org/packages/basilicom/json-schema-request-validator-bundle)[ RSS](/packages/basilicom-json-schema-request-validator-bundle/feed)WikiDiscussions master Synced 1mo ago

READMEChangelog (4)Dependencies (5)Versions (7)Used By (0)

JSON Schema Request Validator Bundle
====================================

[](#json-schema-request-validator-bundle)

Easily validate Symfony request bodies via JSON schema and automatically reject invalid requests

Version
-------

[](#version)

VersionSymfony1.x3.4.x or 4.1.x2.x5.3.x3.x6.4.x or 7.0.xInstallation
------------

[](#installation)

via composer

```
composer require basilicom/json-schema-request-validator-bundle

```

```
use Basilicom\JsonSchemaRequestValidator\JsonSchemaRequestValidatorBundle;
// ...
return [
    // ...
    JsonSchemaRequestValidatorBundle::class => ['all' => true],
];
```

Usage
-----

[](#usage)

The controller needs to implement the `JsonSchemaRequestValidationControllerInterface`. All request bodies of its actions then will be validated with JSON schema files set via the interface method `setJsonSchemaFilePathsInFilePathProvider(FilePathProvider $filePathProvider)`.

All actions of this controller must have a JSON schema file which must be mapped via the route name.

The system automatically rejects an invalid incoming requests with status code "400 Bad Request". If no JSON schema file can be found it will respond with "500 Internal Server Error".

Example Symfony controller
--------------------------

[](#example-symfony-controller)

```
