Laravel 13.43.0 removes duplicated schemas and validation rules
JsonSchema::rules() derives Laravel validation rules from a reusable JSON Schema definition.
Keeping one contract instead of two
When an MCP tool or an API accepts structured input, it is common to define the contract in one place and repeat it in a FormRequest. The schema tells a client or agent what it may send, while Laravel rules protect the input before business logic runs. The trouble starts when a field is added, a limit changes, or an optional value becomes required: both definitions need updating. That duplication does not always break immediately, but eventually it creates two different contracts for the same operation.
Laravel 13.43.0 adds JsonSchema::rules() to derive validation rules from an object schema. The method accepts schemas created with Laravel's builder as well as raw JSON Schema arrays. It does not replace Laravel validation; it generates Laravel rules from a definition that already describes the incoming data. That makes the schema a useful starting point for both declaring and validating an operation's parameters.
From a schema to a FormRequest
In a project where the contract sits close to a tool or endpoint, I can keep using a FormRequest without rewriting basic requirements, types, formats, and limits. JsonSchema::rules() returns rules that can be used wherever Laravel accepts validation rules. That includes Validator::make() and a FormRequest class's rules() method. This example uses Laravel's documented builder and connects HTTP validation to the same schema.
<?php
namespace App\Http\Requests;
use Illuminate\Foundation\Http\FormRequest;
use Illuminate\JsonSchema\JsonSchema;
class CreateServerRequest extends FormRequest
{
public function rules(): array
{
return JsonSchema::rules(JsonSchema::object(fn ($s) => [
'name' => $s->string()->max(50)->required(),
'email' => $s->string()->email()->required(),
]));
}
}A raw JSON Schema array can also be passed directly to JsonSchema::rules(). For instance, an email field with a string type, an email format, and an entry in required becomes the required, string, and email validation rules. This is useful when a schema already lives in configuration, is shared with another component, or comes from a tool definition. There is no need to manually translate it into Laravel rule syntax before validating the request.
A good fit for self-hosted AI services
I find this especially useful for Laravel services that expose tools to agents and run in Docker. In that setup, the input contract is not just an internal concern: it is the interface used by an automated client and by the service that executes the action. Keeping one definition and deriving validation from it reduces the chance that an updated container accepts something different from what the agent expects to send. It also makes reviews easier, because the schema clearly shows which inputs belong to the operation.
This is not an MCP-only feature, and it has no dependency on Docker. It works just as well for an internal API, a webhook, or a normal HTTP form. The difference is that the cost of maintaining two parallel contracts becomes more obvious when several automated consumers are involved. If a project already uses JSON Schema as part of its design, this removes repetitive work.
The important limitations
JsonSchema::rules() does not turn a schema into an application's full security policy. Authorization still belongs in authorize() or the appropriate application layer, while checks that depend on the database, permissions, or system state need additional rules. It also does not replace business logic: valid input shape does not mean an action should be allowed to run. Derived rules should be treated as structural validation and extended where the use case requires it.
I would not introduce this solely to save a few lines if the schema is not reused beyond validation. For a small, purely internal request, a regular Laravel rules array may remain easier to read and maintain. The real value appears when JSON Schema is already a meaningful contract and I want to prevent it from drifting away from the FormRequest. As usual, edge cases still deserve tests instead of assuming that a schema can express every domain-specific condition.
A small change with a practical result
This feature does not change how Laravel validates requests, but it provides a cleaner way to organize shared contracts. If schemas already define the input of tools or APIs, they can be reused instead of maintaining another representation of the same constraints. That removes maintenance points and makes accidental differences between documentation and server behavior less likely. For projects combining Laravel, agents, and self-hosted services, it is a modest addition with clear practical value.
Source: Laravel 13.43.0 on VersionTrack
Official documentation: Deriving rules from JSON Schemas in Laravel