yiisoft/hydrator-validator
Integrates Yii Hydrator with Yii Validator to validate input data while hydrating typed objects and DTOs. Map arrays into objects and enforce validation rules in one step, reducing boilerplate and keeping data checks close to object construction.
Validator::make() call, duplicated per payload type. This collapses it into a single self-validating DTO.FormRequest vs. validation intrinsic to the DTO. That's an architecture standard, and it's the decision worth making deliberately rather than by accretion.Illuminate\Validation — two rule vocabularies, two error shapes, two things to teach new hires.Consider it when:
FormRequest isn't available anyway.Look elsewhere when:
spatie/laravel-data delivers hydration + validation + request integration with a large community, and it's what your engineers already reach for. Default answer.exists, unique, password, custom rule objects). Yiisoft's rules won't match; you'll maintain two vocabularies forever.Illuminate\Validation is real weight for a marginal gain.Executives. This is a small, correctly-scoped utility that does not unlock a new capability — we already validate input. The recommendation is not to adopt it as a standard. The downside of a wrong call isn't an outage; it's quietly accumulating a second validation system that costs us maintenance and onboarding time for years. Revisit only if we deliberately move ingestion logic off the framework's HTTP layer, at which point it becomes a reasonable candidate. Low cost to evaluate, real cost to adopt casually.
Engineering. The honest pitch: it solves "hydrate then validate" in one step for data arriving outside HTTP — jobs, webhooks, imports. That's a real papercut. But if we want that pattern, spatie/laravel-data is the lower-friction answer and keeps us in the ecosystem we hire for and debug in. yiisoft/hydrator-validator is competently built (BSD-3, actively released) and would be my pick if we were prototyping a framework-agnostic ingestion service or evaluating Yii3 — with the caveat that we write the Laravel bridge, the docs, and the error-mapping layer.
Decision requested:
spatie/laravel-data against this package for a single real webhook/import payload. Exit criteria: Laravel rule parity, error-envelope fit, and time-to-first-working-DTO for an engineer who has never seen either library.How can I help you explore Laravel packages today?