Weave Code
Weaver
Helps Laravel developers discover, compare, and choose open-source packages. See popularity, security, maintainers, and scores at a glance to make better decisions.
Feedback
Share your thoughts, report bugs, or suggest improvements.
Subject
Message

Json Validation Bundle Laravel Package

joipolloi/json-validation-bundle

A Symfony bundle for validating JSON payloads against schemas, helping you enforce request structure and return clear validation errors in your PHP applications.

View on GitHub
Deep Wiki
Context7

Technical Evaluation

Architecture fit. There is a framework mismatch that dominates the entire evaluation: joipolloi/json-validation-bundle is a Symfony framework bundle, not a Laravel package. Its value is delivered through three Symfony-specific mechanisms — bundle registration in bundles.php, a Doctrine annotation read by an annotation reader wired into sensio/framework-extra-bundle's argument resolver, and a kernel/controller event listener that intercepts the payload before the controller action fires. Laravel has no bundle registration, no annotation-driven argument resolution, and no equivalent interception point at controller invocation. Roughly 60–80% of the package is scaffolding with no destination in a Laravel application. The remaining 20% — "decode the JSON body, validate against a JSON Schema, reject with a structured error" — is genuinely valuable and reproducible in under 100 lines.

Integration feasibility. Low as a dependency, high as a pattern. composer require would install cleanly and then produce dead code: service definitions, compiler passes, and the annotation reader would never be invoked. Forcing it in would require an adapter that manually instantiates the validator, shims Symfony's HttpFoundation\Request onto Illuminate\Http\Request, and mimics the event dispatcher — a shim that leaks through the call stack and will fracture on getContent()/getPayload() semantics. The realistic path is extraction, not integration: the underlying engine is almost certainly justinrainbow/json-schema, and re-implementing the bundle's behaviour in Laravel is a custom validation rule or FormRequest subclass. Cheaper than any adapter, and maintainable by the team that owns it.

Technical risk. High, and concentrated in provenance. Four stars, zero dependents, and a repository that reads as a 2015–2017-era artifact. Specific exposures:

  1. Version ceiling. The bundle predates PHP 7.4 typed properties, PHP 8 deprecations, and Symfony 5/6. Its Doctrine Annotations dependency is deprecated in favour of native attributes.
  2. No security posture. Zero dependents means no downstream pressure to patch a CVE in its transitive JSON Schema dependency — and schema validation runs directly on attacker-controlled input.
  3. No CI/test signal available from the repository metadata.
  4. Silent scope drift. The supported JSON Schema draft (likely draft-04) may not match the dialect your contract team authors against, producing validation gaps that look like passes.

Key questions.

  • Is the requirement shape validation only (types, required keys), or enforcement of a published OpenAPI/JSON Schema contract shared with external consumers? The answer determines whether dialect compatibility is a hard gate.
  • Does the API surface accept nested objects/arrays where Laravel's array and dot-notation rules genuinely fall short, or is the payload flat enough that first-party rules suffice?
  • Is the schema artifact sourced from a spec repo (contract-first) or hand-authored per endpoint (code-first)? Only the former justifies adopting a schema engine at all.
  • What is the error contract — does the client need RFC 7807 application/problem+json with JSON Pointer paths to failing fields, or is a 422 with a message sufficient?
  • Who owns the implementation if we adopt the pattern — is there appetite to maintain a first-party port in-house?

Integration Approach

Stack fit. Poor as shipped. Mapping the bundle's concerns onto a Laravel stack:

Bundle concern Symfony mechanism Laravel equivalent
Registration Bundle class + kernel None — a service provider has nothing to bind
Schema declaration Doctrine annotation on controller FormRequest::rules(), PHP attribute, or config map
Interception Kernel/controller event listener Middleware or FormRequest authorization/validation
Payload access Request::getContent() $request->json()->all() / $request->input()
Error response Symfony JsonResponse + violations ValidationException → 422 handler

Every row requires translation, and there is no row where the package does work Laravel does not already do.

Migration path — rebuild, don't bridge.

  1. Spike (1–2 days). Install justinrainbow/json-schema — or preferably opis/json-schema for better performance and draft-07/2019-09 support — in a scratch branch and validate three real payloads against their schemas. This de-risks the only technically uncertain element (dialect coverage) without touching production code.
  2. Implement a first-party rule. A JsonSchema validation rule (via Validator::extend or a Rule object) that accepts a schema path, validates the decoded array, and maps violations into Laravel's message bag using JSON Pointer strings as attribute names so frontend field-level error mapping keeps working.
  3. Wrap in a FormRequest base class so endpoint classes declare protected function schema(): string and inherit validation, 422 shaping, and application/problem+json content negotiation.
  4. Close out the dependency and record the decision in the ADR log so the bundle is not re-proposed next quarter.

Compatibility. Two hard gates before step 2: confirm the chosen engine supports the JSON Schema draft your schemas are authored in (draft-04 vs draft-07 vs 2019-09 differ materially on exclusiveMinimum, const, and if/then/else), and confirm the engine is compatible with your PHP runtime (8.1/8.2/8.3) and under active security maintenance. opis/json-schema is the stronger choice on both axes; the bundle's presumed engine is the weaker one.

Sequencing. Validation lands after the schema artifacts stabilise and before any consumer-facing rollout that depends on contract enforcement — building the rule first and the schemas second inverts the dependency and guarantees churn. Run it in shadow mode (validate, log violations, do not reject) for one release cycle on high-traffic endpoints to catch schema/payload drift before it becomes a 422 outage. Sequence the work behind authentication ordering, not alongside it.

Operational Impact

Maintenance. Adopting the bundle transfers a maintenance liability with no upstream counterpart. Forking means owning a Symfony bundle you do not want; porting means owning ~100 lines you fully understand. The port is the lower total cost of ownership by a wide margin and removes a dependency from supply-chain review entirely. Steady-state cost of the first-party version is near zero, revised only when a JSON Schema draft changes or a dependency CVE lands.

Support. There is no support channel. Four stars and zero dependents means no Stack Overflow corpus, no issue triage, and no realistic prospect of an upstream fix to a bug you report. Every defect becomes an in-house defect, discovered in production, on a code path that processes untrusted input — an unfavourable risk profile for a component sitting at the request boundary. The port converts that unknown into a known, owned surface.

Scaling. Schema validation is CPU-bound and synchronous: parse schema, validate payload. On multi-MB bodies or deeply nested arrays this is measurably more expensive than Laravel's native scalar rules, and recursive schemas can be pathological. Mitigations: cache compiled schemas (schemas are static per endpoint — parse once per worker via a container singleton), cap body size at the web server or middleware before validation runs, and enforce maxDepth/maxItems where the engine supports it. The operationally significant failure mode: an unbounded maxItems on an array schema is a cheap DoS vector. This risk is identical whether you use the bundle or a port — it is a property of schema validation, not of this package.

Failure modes.

  • Silent pass on dialect mismatch — the schema uses a keyword the engine does not implement; validation passes when it should fail. Highest severity because it is invisible. Detect with contract tests asserting known-invalid payloads are rejected.
  • Over-strict rejection — a schema tightens (additionalProperties: false) and clients sending benign extra fields start receiving 422s. Mitigate with shadow mode before enforcement.
  • Dependency breakage — a transitive justinrainbow/json-schema update or PHP minor upgrade breaks the abandoned bundle with no upstream fix. This is precisely the failure mode the port eliminates.
  • Error-shape regression — violations surfaced under JSON Pointer keys break the frontend's field-level mapping. Pin the error contract with a test.
  • Middleware ordering — if validation runs before authentication, unauthenticated clients burn CPU on schema validation. Order it after auth.

Ramp-up. For the bundle as shipped: effectively not rampable. A Laravel engineer would spend more time reverse-engineering Symfony's annotation and event machinery than writing the replacement. For the port: half a day for a mid-level engineer comfortable with Laravel validation, plus a day for whoever owns the schema artifacts to confirm dialect and draft. The practical recommendation is to reject the dependency and adopt the pattern — a small, low-risk engineering task with an identical outcome and none of the supply-chain exposure.

Weaver

How can I help you explore Laravel packages today?

Conversation history is not saved when not logged in.
Prompt
Add packages to context
No packages found.
elsayed85/laravel-api-exceptions
ouhssini/laravel-demo-mode
daworks/ncloud-outbound-mailer-driver
gp247/cms
ignibyte/aic-gates
nexa-merchant/blog
novasa/laravel-language-center
opencage/geocode
adolfoholzer/parameters
livenetworks/ln-starter
shitoudev/permissionmanager
johannesclimacus/laravel-tui
hocvt/seotools
vitalybaev/sypexgeo
amphibee/themosis-ignition
gito-me/fast-excel
frankyso/laravel-ipaymu
geolize-studio/laravel-chile
boomerangui/chat
cgv/localized-resource