respect/validation
Powerful PHP validation engine with 150+ tested validators. Build readable, chainable rules like numeric()->positive()->between(). Includes advanced exception handling and thorough docs. Great for complex input validation in any PHP app.
v::email()->notBlank()->assert($input)).v::between(18, 120)->validate($user['age'])) in Laravel models, API requests, or CLI commands.ResultQuery objects for consistent UX (e.g., API responses, frontend feedback).#[Email] public string $email in DTOs).v::factory(fn($input) => v::key('confirmation', v::equals($input['password'])))).Request objects) with reusable pipelines.FormRequest::rules() with fluent validation for complex logic (e.g., nested arrays, custom business rules).User, Order) during creation/update via v::attributes().v::numericVal()->positive()->assert($input)).v::email()->assert($email)).if/elseif validation chains with maintainable, composable rules.Validator facade (e.g., v::numericVal()->between(1, 100) vs. ['min', 'max']).ResultQuery for API error responses with paths like .user.address.city).FormRequest rules suffice).Validator::extend(), Rule objects) and prefer ecosystem-native solutions."Respect\Validation is a battle-tested, MIT-licensed PHP package that replaces manual or ad-hoc validation with a maintainable, composable system. It reduces bugs in user input handling by enforcing rules declaratively (e.g., v::email()->notBlank()), cuts development time by 30–50% for validation-heavy features, and improves data quality across APIs, forms, and CLI tools. With >150 validators and support for complex nested validation, it’s ideal for scaling Laravel applications while keeping validation logic DRY and testable. The package’s attribute-based validation (PHP 8.5+) also aligns with modern OOP practices, making it future-proof."
ROI:
*"This package lets you write validation once, use it everywhere—whether in Laravel API requests, domain models, or CLI tools. Key advantages:
v::numericVal()->positive()->between(1, 100)..user.address.city) for granular error reporting.#[Email], #[Between(18, 120)] for type-safe validation.v::factory(fn($input) => v::equals($input['password']))).Validator.Migration Path:
FormRequest::rules() with v::email()->notBlank()->assert($request->all()).v::attributes() to validate annotated entities.if chains for v::allOf(v::email(), v::notBlank())->assert($input).Example:
// Before: Manual checks in a controller
if (!filter_var($request->email, FILTER_VALIDATE_EMAIL)) {
throw new \InvalidArgumentException('Invalid email');
}
if ($request->age < 18) {
throw new \InvalidArgumentException('Must be 18+');
}
// After: Declarative validation
v::allOf(
v::email(),
v::key('age', v::between(18, 120))
)->assert($request->all());
```"*
**Trade-offs**:
- **Learning Curve**: PHP 8.5+ features (attributes, union types) may require team upskilling.
- **Migration Effort**: v3.0 has breaking changes (see [Migration Guide](https://respect-validation.readthedocs.io/en/3.0/migrating-from-v2-to-v3/)).
- **Laravel Integration**: Not a drop-in replacement for `Validator` facade (but can coexist)."
How can I help you explore Laravel packages today?