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

Api Validator Laravel Package

twentytwo-labs/api-validator

Twentytwo Labs API Validator is a Laravel/PHP package for validating API requests and responses with reusable rules. It helps keep endpoints consistent, catches malformed payloads early, and makes validation errors easier to surface in your applications.

View on GitHub
Deep Wiki
Context7

Technical Evaluation

Verdict up front: conditionally viable as a thin, replaceable contract-validation layer; not viable as a core dependency without a spike and an abstraction seam.

Architecture fit — The package is PSR-7 native, which is the right primitive but the wrong shape for a stock Laravel app. Laravel's HTTP layer is Symfony HttpFoundation; PSR-7 only enters if we add symfony/psr-http-message-bridge plus a PSR-7 implementation (e.g. nyholm/psr7). Net: this is a framework-agnostic PHP component we would wrap, not a Laravel package we install and configure. Its natural usage shape is middleware — validate the request before the controller runs — which maps cleanly onto Laravel middleware or a FormRequest replacement.

Integration feasibility — Moderate. The real work sits in three places: (1) request/response bridging between HttpFoundation and PSR-7, (2) mapping validator failures onto Laravel's 422 / ValidationException contract so API consumers see a consistent error envelope, (3) loading and caching the OpenAPI document. None are exotic; all become ours to own.

Technical risk

  • Adoption: 0 stars, 0 dependents — no battle-testing, no community corpus, effectively single-maintainer. Treat as a code dependency we may have to fork.
  • Scope ambiguity: "OpenAPI/Swagger2" phrasing suggests OpenAPI 2.0 heritage. Confirm 3.0/3.1 support before committing, since most current specs are 3.x.
  • Crowded niche: league/openapi-psr7-validator is the de facto standard here with real production usage. Any decision must be a bake-off against it, not a unilateral pick.
  • Performance: schema parsing and $ref resolution on the hot path is the classic failure mode; requires precompiled/cached schema artifacts.
  • Metadata anomaly: the "last release 2026-08-31" date is future-dated or mis-tagged, so release cadence cannot be used as a health signal — inspect tags directly.
  • License: Apache-2.0, so fork/modify/vendor is safe.

Key questions

  1. Does it support OpenAPI 3.0/3.1, and to what depth (oneOf/anyOf, discriminators, nullable, format assertions)?
  2. Is it spec-compliant on parameter style/content handling, or a useful subset?
  3. Is failure output structured enough to remap into field-level 422 errors?
  4. What is p95 overhead per request at our payload sizes, and can the schema be cached across workers?
  5. Who maintains it, and is there a security disclosure path?
  6. Why this over league/openapi-psr7-validator?

Integration Approach

Stack fit — PHP 8.x / Laravel 10–11, PSR-7 bridge, with the OpenAPI document treated as a versioned contract artifact in CI. Fits best where the spec is already authoritative rather than aspirational.

Migration path — Non-destructive and incremental: attach as middleware on selected route groups in shadow mode (log-only, never block), then promote to enforcing. No data migration and no consumer-visible change while shadowing.

Compatibility — Verify psr/http-message 1.x vs 2.x against the bridge and any existing PSR-7 dependency; version skew here is the most common install-time breakage. Confirm worker safety under Octane/Swoole if we run long-lived processes.

Sequencing

  1. Spike (2–3 days): validate three representative endpoints, measure overhead, compare correctness against the league implementation. Gate: does it match or beat on spec coverage?
  2. Abstraction seam: our own ContractValidator interface plus adapter, so the library underneath is swappable. This is the whole risk mitigation.
  3. Schema pipeline: cached/compiled resolved document, refreshed on deploy, never parsed per request.
  4. Error mapping: adapter → ValidationException with field paths matching existing API conventions.
  5. Shadow rollout on one API surface; diff against existing FormRequest rules to surface contract drift.
  6. Enforce route group by route group; document as the CI/deploy contract gate.

Operational Impact

Maintenance — We own the bridge and error mapping; expect to vendor or fork if upstream stalls. Budget a few days per year for upstream bumps, plus the ongoing cost of keeping the OpenAPI document truthful — spec staleness is the real maintenance tax, not the library.

Support — No community, no docs ecosystem, no Stack Overflow corpus. Internal-only: one named engineer must own it. That falls below the bar for tier-1 critical-path services unless the abstraction seam exists.

Scaling — Validation is CPU-bound on top of Laravel's own boot. Mitigate with cached/compiled schemas, validating only mutating methods, and sampling in shadow mode. Under Octane, preload the schema once per worker. Measure before enforcing globally on high-volume endpoints.

Failure modes

  • Upstream abandonment → fork or swap behind the interface (contained only if the seam exists).
  • Spec drift → false 422s blocking valid traffic, indistinguishable from real defects.
  • Unresolvable $ref or malformed document → 500s at boot or first request; fail closed at deploy time.
  • Bridge mismatch on raw bodies / multipart → validation silently skips uploads; test explicitly.
  • Overlap with existing FormRequest rules → duplicated, divergent validation logic.

Ramp-up — Low for a mid-level Laravel engineer comfortable with PSR interfaces: ~1 week to productive, ~2–3 weeks to own it responsibly. The learning curve is OpenAPI semantics, not this library.

TPM recommendation — Do not adopt directly on a tier-1 service. Run the spike explicitly as a bake-off against league/openapi-psr7-validator, and adopt only behind a thin internal interface. The value is opportunistic (contract validation, shadow-mode API governance), not foundational.

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.
tequilarapido/trackit
gregsphotography/site-builder-filament
cabaoctavio/laravel-query-log
gregsphotography/site-builder-components
io-digital/clickatell
snowsoft/laravel-admin
oxygen/auth
relicsoftware/barakah-payment-gateway
tobya/work-with-composer
equipc/laravel-email-validator
equipc/laravel-email-database-log
adedsec/nova-translated-labels
wazza/laravel-db-encryption
hokny/laravel-generator
vonsogt/backup
jengo/queues
jeremykenedy/laravel-observability
coleus/frame
thtg88/journalism
filagora/filagora-ai-forums