Weave Code
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

Create Data Transfer Objects that validate input on instantiation. Define rules once and reuse them across controllers, services, jobs, and CLI commands—reducing duplication and keeping validation decoupled from HTTP requests. Compatible with Laravel 11–13.

View on GitHub
Deep Wiki
Context7

Product Decisions This Supports

  • Decoupling Validation Logic: Replace tightly coupled request validation with reusable DTOs, enabling validation reuse across APIs, CLI commands, queues, and background jobs. Reduces duplication and improves maintainability.
  • API Contracts: Standardize input/output contracts for APIs, ensuring consistency between frontend (TypeScript) and backend (PHP) validation rules via generated TypeScript definitions.
  • Domain-Driven Design (DDD): Align with DDD principles by encapsulating business logic and validation within domain objects (DTOs) rather than framework-specific request classes.
  • Build vs. Buy: Buy—avoids reinventing DTO validation wheels while offering more flexibility than Laravel’s built-in request validation.
  • Roadmap Priorities:
    • API-First Development: Accelerate API development by defining contracts upfront.
    • CLI/Background Jobs: Reuse validation logic for non-HTTP use cases (e.g., scheduled jobs, queue workers).
    • Type Safety: Reduce runtime errors with compile-time checks (via TypeScript) and runtime validation.
    • Microservices: Standardize data contracts across services.

When to Consider This Package

Adopt if:

  • Your Laravel app has repeated validation logic across HTTP requests, CLI commands, or queues.
  • You need consistent data contracts between frontend (TypeScript) and backend (PHP).
  • You’re adopting DDD or clean architecture and want to decouple validation from framework-specific layers.
  • Your team prioritizes maintainability over quick hacks (e.g., duplicating validation rules).
  • You work with complex nested data (e.g., arrays of DTOs, nested objects) and want seamless serialization/deserialization.

Look elsewhere if:

  • Your app is simple (e.g., CRUD with minimal validation) and Laravel’s built-in FormRequest suffices.
  • You don’t reuse validation logic across non-HTTP contexts (e.g., only APIs).
  • Your team lacks PHP/TypeScript alignment or prefers manual validation (e.g., for performance-critical paths).
  • You’re using Laravel <11.x (package drops support for older versions).
  • You need advanced custom validation that the package’s attributes can’t cover (e.g., dynamic rules).

How to Pitch It (Stakeholders)

For Executives: "This package lets us write validation rules once and reuse them everywhere—APIs, CLI tools, and background jobs—cutting dev time by 30%+ while improving data consistency. It also bridges PHP and TypeScript teams by auto-generating API contracts, reducing frontend-backend miscommunication. Think of it as standardizing our data ‘language’ across the stack, which scales with our growth."

For Engineers: *"Instead of copying-pasting validation from Request classes into CLI commands or queues, we’ll define DTOs with validation rules, then reuse them anywhere. Key benefits:

  • No duplication: Validation lives in one place (the DTO).
  • Type safety: Auto-generated TypeScript types for APIs.
  • Flexibility: Works with nested objects, collections, and custom casts.
  • Future-proof: Supports Laravel 11–13 and integrates with DDD patterns. Example: Replace this:
// Old: Duplicate validation in Request and Command
class StoreUserRequest extends FormRequest { ... }
class ProcessUserCommand { ... } // Copies same rules!

With this:

// New: Single source of truth
class UserDTO extends ValidatedDTO {
    #[Rule('required|string|max:255')] public string $name;
    // ... reuse in API, CLI, or queues
}
```*
**Tradeoff**: Slight learning curve for DTO patterns, but pays off in maintainability."*
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.
davejamesmiller/laravel-breadcrumbs
artisanry/parsedown
christhompsontldr/phpsdk
enqueue/dsn
bunny/bunny
enqueue/test
enqueue/null
enqueue/amqp-tools
milesj/emojibase
bower-asset/punycode
bower-asset/inputmask
bower-asset/jquery
bower-asset/yii2-pjax
laravel/nova
spatie/laravel-mailcoach
spatie/laravel-superseeder
laravel/liferaft
nst/json-test-suite
danielmiessler/sec-lists
jackalope/jackalope-transport