New

Just launched: Vueblocks, a brand-new search engine for Vue packages! Explore Vueblocks →

wt-health/laravel-json-schema-request

Like FormRequests, but for validating against a json-schema
60,256 1
Install
composer require wt-health/laravel-json-schema-request
Latest Version:v4.0.0
PHP:^8.3|^8.4
Laravel:12 · 13
Older releases:7 – 11
License:MIT
Last Updated:Oct 22, 2026
Links: GitHub  ·  Packagist
Maintainer: webtoolshealth

JSON Schema Request

CI Action Code Coverage Scrutinizer Code Quality

Laravels Form Request Validation for JSON Schema documents

Installation

 composer require wt-health/laravel-json-schema-request

Usage

The development experience is identical to Laravel's Form Request Validation, except instead of writing Laravel validation rules, you write a JSON Schema.

You can create a new request using the make:json-request command

artisan make:json-request MyJsonRequest

You will now have new request class App\Http\Requests\MyJsonRequest, Below you can see a basic example schema.

<?php

namespace App\Http\Requests;

use Wthealth\JsonSchemaRequest\JsonSchemaRequest;

class MyJsonRequest extends JsonSchemaRequest
{
    public function schema(): array
    {
        return [
            'type' => 'object',
            'properties' => [
                'first_name' => ['type' => 'string'],
                'last_name' => ['type' => 'string'],
                'email' => ['type' => 'string', 'format' => 'email'],
            ],
            'required' => ['first_name', 'last_name', 'email'],
            'additionalProperties' => false,
        ];
    }
}

Once you have a JsonSchemaRequest object, all you need to do is type-hint the request on your controller method. The incoming form request is validated before the controller method is called.

public function store(MyJsonRequest $request)
{
    // The incoming request is valid...

    // Retrieve the validated input data...
    $validated = $request->validated();
}

License

The MIT License (MIT). Please see License File for more information.

Related Packages

mesak/laravel-opis-validator

Laravel FormRequest With Opis Validator

5,000 1
cline/json-schema

Immutable JSON Schema implementation with support for drafts 2020-12, 2019-09, d...

1,253 0
claraleigh/naughty-username

Validate that a username is not a naughty one

24,243 0
cohensive/validation

Extra functionality for Laravel 5 Validator.

13,938 14
jedrzej/validator-extended-syntax

Laravel 4/5 package that adds validator negation to Laravel's validation module

11,580 3

Version History

Version Released PHP Laravel License
v4.0.0 ^8.3|^8.4 ^12.0|^13.0 MIT
v3.2.0 ^8.3|^8.4 ^11.0|^12.0 MIT
3.1.0 ^8.3|^8.4 ^11.0|^12.0 MIT
v3.0.0 ^8.2|^8.3 ^10.0|^11.0 MIT
v2.0.0 ^8.0|^8.1|^8.2 ^8.0|^9.0|^10.0 MIT