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

Laravel Validated Dto Laravel Package

wendelladriel/laravel-validated-dto

Validated DTOs for Laravel: extend ValidatedDTO, declare typed properties and validation rules, and get validated, cast, type-safe data objects from request payloads. Includes built-in casts and config publishing for cleaner controllers.

View on GitHub
Deep Wiki
Context7

Technical Evaluation

Architecture fit. The package slots cleanly into Laravel's existing validation pipeline rather than competing with it. DTOs extend ValidatedDTO, declare typed properties, and supply rules(), defaults(), and casts() — all of which are Laravel-native concepts (rules, Validator, Sometimes, Password, etc.). Construction is polymorphic (fromArray, fromRequest, fromJson, from Eloquent models, from artisan input), and the container can resolve DTOs directly into controller actions. For teams already using Laravel's form requests or manual validation, this is an additive, low-ceremony refactor path. It is a thin abstraction over illuminate/validation, not a new validation engine, which is exactly the right architectural posture for a utility package.

Integration feasibility. Very high. composer require wendelladriel/laravel-validated-dto, optional config publish, and adoption can be scoped to a single feature. No database migrations, no service provider conflicts, no queue/event surface. Because the DTO is resolved from the current request via the container, it can replace form requests without rewriting controllers. Casting (StringCast, BooleanCast, enum/Carbon handling) is where most of the value lands — it normalizes HTTP input into typed domain objects at the boundary.

Technical risk.

  • Maintainer concentration. Effectively a single-maintainer project (Wendell Adriel). Bus factor is the dominant risk; there is no vendor SLA.
  • Ecosystem validation gap. The repo reports 0 dependents, meaning little public downstream evidence of long-running production use. That is a signal to treat it as "promising but not battle-hardened at scale" rather than a default choice.
  • API churn. The v3.x → v4.x line shows meaningful churn (lazy validation, SkipOnTransform attribute, after hook, changed buildDataForExport visibility, JSON-serializable fixes). Semantic-version discipline looks reasonable on major bumps, but minor releases have changed behavior around casting and transformation more than once (e.g., empty-string number casts, timezone-preserving Carbon).
  • Reflection-based magic. Typed properties plus reflection mean misalignment between rules(), casts(), and declared properties can fail at runtime rather than at static analysis time.
  • Validation semantics. Because it wraps Laravel's validator, behavior on sometimes, file uploads, and nested DTOs inherits Laravel's quirks — generally fine, but worth pinning with tests.

Key questions for the maintainer/team.

  1. What is the intended support window per major Laravel version, and how quickly is a new Laravel major picked up? (v4.5.0 added Laravel 13 support — good signal, but policy is unclear.)
  2. Is there a documented security disclosure SLA beyond SECURITY.md existence?
  3. How is backward compatibility handled for casts()/defaults() behavior changes in minor releases?
  4. What is the recommended pattern for nested DTOs and collections in large domains?
  5. Do we accept single-maintainer risk, or do we need an internal fork/guardrail policy?

Integration Approach

Stack fit. Best fit is a PHP 8.1+ Laravel application (10/11/12/13 supported per release notes) that already leans on Laravel validation and has, or wants, a typed boundary between HTTP and domain layers. It fits poorly in codebases that deliberately avoid reflection-heavy patterns or that need DTO serialization beyond Laravel's toArray/JSON conventions.

Migration path. Do not attempt a big-bang replacement of form requests. Recommended path:

  1. Introduce the package in a single bounded context (e.g., one API resource group).
  2. Replace inline $request->validate(...) and form requests in that area with DTOs.
  3. Establish team conventions (naming, casts() usage, one DTO per operation) before expanding.
  4. Backfill adjacent modules only after the first slice has survived a release cycle.

Compatibility.

  • Requires Composer/PSR-4 and aligns with Laravel's illuminate/validation and container.
  • Enum and Carbon casting are supported; timezone preservation has been explicitly fixed (v3.7.1), so date-heavy APIs are viable.
  • Arrayable and JSON serialization are supported, which matters for API responses and nested structures.
  • Pin to ^4.x and lock the exact version; track releases for behavior-affecting minors.

Sequencing.

  1. Week 0: Proof of concept on one endpoint; verify container injection, casting, and error formatting match existing API contracts.
  2. Week 1–2: Define DTO conventions and a lint/test template; add to CI.
  3. Week 2–4: Roll out to one service area; measure diff size and review burden.
  4. Post-cycle: Decide on wider adoption based on maintainer responsiveness and upgrade friction.

Operational Impact

Maintenance. Low ongoing cost by design — no runtime services, no schema, no background jobs. The real maintenance burden is version tracking: each Laravel major requires a compatible package release, and each package minor may alter casting/transformation behavior. Mitigate with a pinned version, a standing upgrade ticket per Laravel cycle, and a small internal test suite around DTO construction and error shapes.

Support. Community-supported only. There is no commercial backing, no guaranteed response time, and a single primary maintainer. Operationally this means the adopting team must own the abstraction: designate an internal owner, keep a documented convention guide, and be prepared to fork or vendor the package if upstream stalls. The MIT license makes forking viable and low-risk legally.

Scaling. Runtime overhead is negligible — DTO construction is reflection plus a Validator call, which is the same order of cost as a form request. Validation happens at the boundary, so it scales the same way the framework does. The scaling risk is organizational, not technical: DTO proliferation (one class per endpoint variant) can create a maintenance surface that grows faster than the value delivered. Enforce conventions early and consider shared base DTOs for common shapes.

Failure modes.

  • Validation exceptions surface as ValidationException — consistent with Laravel, but if the existing API does not use Laravel's error format, response contracts can shift. Test error payloads explicitly.
  • Reflection/property mismatch — a declared property absent from rules()/casts() or vice versa can produce confusing missing-property or type errors at runtime.
  • Upstream stall — if a future Laravel major is not supported promptly, the package becomes a blocker. Mitigation: fork policy and a documented exit plan.
  • Silent behavior drift on minor upgrades — casting changes (empty strings, dates, enums) can subtly alter downstream data. Mitigation: pin and regression-test on upgrade.
  • Nested complexity — deeply nested DTOs and collections have a history of edge cases; keep nesting shallow and covered by tests.

Ramp-up. High developer fluency with Laravel validation transfers directly; learning cost is measured in hours, not days. The main onboarding investment is convention-setting (naming, casting policy, when to use DTOs vs. form requests), which is a team-lead responsibility, not a training program. Plan for a short internal demo plus a written convention doc, and expect productive output within the first sprint for developers already comfortable with Laravel.

TPM verdict. A well-scoped, low-risk utility with clear ergonomic upside and a modest, honest risk profile dominated by single-maintainer concentration and thin public adoption evidence. Approve for scoped adoption with pinned versions, an internal owner, and a documented fork contingency — not as foundational infrastructure.

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.
dakiquang/laravel-oauth-refresh-lock
woda/laravel-worktrees
dalefranks/ramasite
faghy/laracashbook
roundly-consulting/google-places-for-laravel
roundly-consulting/kubernetes-api-for-laravel
roundly-consulting/plausible-for-laravel
gvp/gvp-laravel-template
metasyncsite/laravel-metasync-client
roundly-consulting/onboarding-for-laravel
andydefer/laravel-notification
adachsoft/cli-process-tester
jhaskell13/laraflow
sebastienheyd/boilerplate-media-manager
ccast/tagixo-primix
pretendtrue/laravel-builder
sawmainek/laravel-scout-tntsearch-driver
tomshaw/laravel-calendar-table
dibakar/laravel-ownership
adachsoft/changelog-linter