PHPackages                             henriqueramos/laravel\_json\_schema\_validator - 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. henriqueramos/laravel\_json\_schema\_validator

ActiveLibrary[Validation &amp; Sanitization](/categories/validation)

henriqueramos/laravel\_json\_schema\_validator
==============================================

Laravel JSON Schema Validator it's a Composer package created to help us to validate JSON Schemas.

1.0.4(6y ago)924.6k↓37.7%9[4 PRs](https://github.com/henriqueramos/laravel-json-schema-validator/pulls)MITPHPPHP &gt;=7.3

Since Apr 27Pushed 2y ago2 watchersCompare

[ Source](https://github.com/henriqueramos/laravel-json-schema-validator)[ Packagist](https://packagist.org/packages/henriqueramos/laravel_json_schema_validator)[ Docs](https://henriqueramos.eti.br/opensources)[ RSS](/packages/henriqueramos-laravel-json-schema-validator/feed)WikiDiscussions master Synced 1mo ago

READMEChangelogDependencies (6)Versions (9)Used By (0)

JSON Schema Validator for Laravel
=================================

[](#json-schema-validator-for-laravel)

**JSON Schema Validator for Laravel** it is a `Composer` package created to validate JSON objects against [JSON Schemas](https://json-schema.org) as an `Illuminate\Validation\Validator` custom rule.

[![Build Status](https://camo.githubusercontent.com/ebb98946fcc7f87794b8a0758fc9e50a4db4187f404989600f297810d985ae30/68747470733a2f2f7472617669732d63692e6f72672f68656e726971756572616d6f732f6c61726176656c2d6a736f6e2d736368656d612d76616c696461746f722e7376673f6272616e63683d6d6173746572)](https://travis-ci.org/henriqueramos/laravel-json-schema-validator) [![Scrutinizer Code Quality](https://camo.githubusercontent.com/36e3c628959313e83d341c5a2ffed2b62c046d727c2c6d402518f3681f6a439b/68747470733a2f2f7363727574696e697a65722d63692e636f6d2f672f68656e726971756572616d6f732f6c61726176656c2d6a736f6e2d736368656d612d76616c696461746f722f6261646765732f7175616c6974792d73636f72652e706e673f623d6d6173746572)](https://scrutinizer-ci.com/g/henriqueramos/laravel-json-schema-validator/?branch=master) [![Latest Stable Version](https://camo.githubusercontent.com/40c03be66d3ba73de1629082d6573e32f953fe9e59b69578c7f271272526577a/68747470733a2f2f706f7365722e707567782e6f72672f68656e726971756572616d6f732f6c61726176656c5f6a736f6e5f736368656d615f76616c696461746f722f762f737461626c65)](https://packagist.org/packages/henriqueramos/laravel_json_schema_validator) [![License](https://camo.githubusercontent.com/39cc7c7b6bf902ee2214f934148848cb22c89d6858c449f3bd46827142df7817/68747470733a2f2f706f7365722e707567782e6f72672f68656e726971756572616d6f732f6c61726176656c5f6a736f6e5f736368656d615f76616c696461746f722f6c6963656e7365)](https://packagist.org/packages/henriqueramos/laravel_json_schema_validator)

About
-----

[](#about)

This package works only at Laravel versions `>= 5.8`. And PHP version `>= 7.3`.

We uses the incredible package `swaggest/json-schema` as a dependency to make everything [works like magic](https://tvtropes.org/pmwiki/pmwiki.php/Main/ClarkesThirdLaw).

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

[](#installation)

Add the following line to the `require` section of `composer.json`:

```
{
    "require": {
        "henriqueramos/laravel_json_schema_validator": "^1.0.0"
    }
}
```

Setup
-----

[](#setup)

1. Run `php artisan vendor:publish --provider="RamosHenrique\JsonSchemaValidator"`. This will create on your `config` folder a file named `json_schema_validator.php`.
2. In your `.env` file, add your JSON Schema files storage path with key `JSON_SCHEMA_VALIDATOR_STORAGE_PATH` (i.e `JSON_SCHEMA_VALIDATOR_STORAGE_PATH=storage/jsonschemas/`).
3. Set up your [JSON Schema file](#what-is-a-json-schema)

What is a JSON Schema
---------------------

[](#what-is-a-json-schema)

We supported the following schemas:

- [JSON Schema Draft 7](http://json-schema.org/specification-links.html#draft-7)
- [JSON Schema Draft 6](http://json-schema.org/specification-links.html#draft-6)
- [JSON Schema Draft 4](http://json-schema.org/specification-links.html#draft-4)

Here's an example for JSON Schema and a valid payload for him:

```
$schemaJson =
