wt-health/laravel-json-schema-request
A Laravel package for validating incoming requests against JSON Schema definitions. Define schemas once, keep controllers clean, and get precise, standards-based validation errors for your API or application requests.
Architecture fit. wt-health/laravel-json-schema-request occupies the HTTP boundary layer, replacing or extending Laravel's FormRequest so that request payloads are validated against a JSON Schema document rather than an imperative rules() array. It fits cleanly where JSON Schema (or an OpenAPI/AsyncAPI contract that compiles to it) is already the source of truth: API-first services, public partner APIs, and event-ingress endpoints where the same schema is shared with consumers. It is a poor fit for teams whose validation logic is inherently procedural (conditional rules across DB state, Rule::unique, custom closures) — those must be re-expressed in schema or pushed into handler code.
Integration feasibility. Mechanically low-cost: a Composer require, extending the package's request base class, and publishing config. The real integration work is authoring and governing the schemas, plus adapting exception handling and test assertions, since Laravel's assertJsonValidationErrors / $errors bag semantics do not map one-to-one onto JSON Schema violation output.
Technical risk.
403 on failed authorize() is the Laravel-idiomatic behavior and is therefore a correctness improvement, but it is an observable contract change for any consumer (mobile client, partner integration, generated SDK, status-code-based retry logic) that was coded against the previous status. Treat this as an API-versioning event, not a bug fix.$ref resolution, format assertions). That dependency, not this package, dictates correctness and CVE exposure.Key questions.
$ref fetches disabled by default?SECURITY.md and a disclosure path? Who has release rights on the repo?Stack fit. Constrain to Laravel 12/13 applications on a modern PHP runtime. Do not attempt to backport; the maintainer has explicitly severed L11.
Migration path.
^3.2.0 on all Laravel 11 services and record them as explicitly frozen — schedule their Laravel 12/13 upgrade rather than a package upgrade.assertJsonValidationErrors usage with assertions on the schema-violation payload.Compatibility. Audit for other packages that type-hint or subclass Illuminate\Foundation\Http\FormRequest in ways that interact with the package's base class, and for any middleware or exception handler keyed on authorization status.
Sequencing. Dev branch → contract tests green (including a negative-path test asserting 403) → staging with production-shaped payloads → production. Keep the release behind a feature flag only if the request classes are numerous enough that rollback-by-redeploy is impractical.
Maintenance. Low ongoing code maintenance, non-trivial governance maintenance. Schemas become versioned artifacts requiring review, ownership, and a deprecation policy. Expect one forced major upgrade per year, timed to Laravel's release cadence, plus a 6–12 month tail of lagging services. Budget roughly one engineer-week per annual cycle across the fleet.
Support. Community-only: GitHub issues, no SLA, no vendor. Escalation path is "read the source" — the package is small enough that this is viable. Identify and document an internal owner who can patch a fork if the upstream stalls.
Scaling. Validation is CPU-bound and synchronous in the request path. JSON Schema validation is generally more expensive than Laravel's rule engine, and cost scales with schema size and $ref graph depth. Mitigate by compiling/caching schema objects per endpoint, keeping schemas flat, disabling remote reference resolution (also an SSRF and latency hazard), and capping request body size at the edge. Load-test representative endpoints before wide rollout rather than assuming parity with the previous validator.
Failure modes.
$ref fetch causing outbound calls to attacker-influenced URLs.Ramp-up. Engineers must learn JSON Schema (draft semantics, oneOf/anyOf pitfalls, additionalProperties) rather than Laravel's rule DSL, and must internalize that error messages are machine-oriented and less human-friendly by default. Plan ~1–2 days per engineer plus a shared internal style guide for schema authoring; without it, schema quality will diverge across teams faster than rule-based validation ever did.
How can I help you explore Laravel packages today?