justinrainbow/json-schema
A PHP library for validating JSON data against JSON Schema definitions, supporting Draft-3, Draft-4, Draft-6, Draft-7, and Draft 2019-09. Install via Composer to validate payloads and catch structural or schema errors.
property + message pairs map cleanly to API error objects), and configuration/feature-flag validation at startup.CHECK_MODE_COERCE_TYPES and CHECK_MODE_APPLY_DEFAULTS let you accept loosely typed form/HTTP input ("17" → 17, "true" → true) and fill optional fields without extra glue code — a small but real reduction in client-side friction and support tickets.$ref, oneOf/anyOf, format checks, strict mode) is genuinely expensive. Delegating to a 3.6k-star, MIT-licensed, actively released library is the cheaper and lower-risk path.Adopt when:
Look elsewhere or mitigate when:
$ref resolution is in the request path. URI retrieval can fetch external schemas; treat that as a trust boundary (allow-list, local-only refs, no user-supplied schema URLs) or you inherit an SSRF/supply-chain surface.CHECK_MODE_STRICT is limited to Draft-6/7/2019-09; older drafts get non-strict behavior only.For executives — the one-paragraph version:
We validate JSON payloads by writing schemas instead of bespoke validation code. justinrainbow/json-schema is the established PHP implementation of the JSON Schema standard: MIT-licensed, ~3.6k GitHub stars, actively released with a public changelog and CI, and it supports the schema drafts our partners and internal contracts already use. Adopting it converts validation from repeated engineering work into configuration, shortens delivery on every endpoint that accepts structured input, and gives us machine-readable, consistent error responses. The cost is one Composer dependency and no license review.
For engineering — the practical framing:
SchemaRule/form request that wraps Validator, map getErrors() straight to 422 responses.CHECK_MODE_COERCE_TYPES and CHECK_MODE_APPLY_DEFAULTS only where you accept untrusted/messy input, and know they mutate the payload.$ref resolver: prefer local/inline refs (SchemaStorage::addSchema with a base URI) over fetching remote schemas at request time.For the roadmap discussion: Low-risk, high-leverage infrastructure. It doesn't open a new product surface on its own, but it is a prerequisite that de-risks and accelerates every integration, webhook, and partner-onboarding story on the roadmap. The single decision to make now is which schema draft becomes our standard — recommend Draft-7 today, with a note that 2020-12 support requires a separate evaluation.
How can I help you explore Laravel packages today?