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

Validation Laravel Package

respect/validation

Respect\Validation is a PHP validation engine offering over 150 fully tested validators. Chain rules fluently, as in v::numericVal()->positive()->between(1, 255)->isValid($input), with advanced exception handling and clear documentation.

View on GitHub
Deep Wiki
Context7

Respect\Validation is a powerful, fluent validation engine for PHP that makes complex validation rules simple and readable. Chain validators together with an expressive API—v::numericVal()->positive()->between(1, 255)->isValid($input)—and get clear, actionable results. With over 150 fully tested validators and advanced exception handling, it handles everything from simple type checks to intricate business rules.

  • Fluent chaining for composing readable, reusable validation rules
  • 150+ validators covering strings, numbers, dates, files, and more
  • Advanced exception handling with detailed, customizable error messages
  • Extensive documentation and a fully tested, actively maintained codebase
  • Framework-agnostic integration, easy to drop into any PHP project
Frequently asked questions about Validation
How do I integrate Respect/Validation into a Laravel project?
Install via Composer: `composer require respect/validation`. Use it alongside Laravel’s Validator by injecting the `Validation` class into Form Requests or services. Example: `$validator = new Validation(); $validator->numeric()->positive()->validate($input)`. No Laravel-specific setup is required beyond Composer.
Can I use Respect/Validation to replace Laravel’s built-in Validator?
Yes, it’s fully compatible. Replace `Validator::make()` with Respect’s chainable syntax (e.g., `v::email()->validate($request->input())`) in Form Requests, API resources, or anywhere. The package doesn’t conflict with Laravel’s core, so you can mix and match.
Does Respect/Validation support Laravel’s Form Request validation rules?
Absolutely. Use it in `FormRequest::rules()` by returning an array of Respect’s validator methods (e.g., `['email' => v::email()->noWhitespace()]`). It integrates seamlessly with Laravel’s validation pipeline, including error message formatting and failed validation responses.
What Laravel versions does Respect/Validation support?
It works with Laravel 5.5+ (PHP 8+). While it’s framework-agnostic, the package’s lightweight design ensures no conflicts with Laravel’s service container or dependency injection. Tested thoroughly with Laravel 9/10, but older versions (5.5+) should work without issues.
How do I handle nested validation (e.g., arrays or objects) in Laravel?
Use Respect’s path-based validation: `v::arrayVal()->key('user')->email()->validate($data)`. For Laravel API Resources, nest rules under `resources:array` or use `->path('user.address')` for deep validation. The package handles nested structures like Laravel’s `Validator::extend()`.
Are there performance concerns when using Respect/Validation in high-traffic Laravel APIs?
No, it’s optimized for performance (~100KB) with no reported overhead. Benchmarks show it handles high-throughput validation (e.g., 10K+ requests/sec) without issues. For Laravel APIs, pair it with caching (e.g., `Validator::extend()` caching) for further optimization.
How do I create custom validation rules for Laravel with Respect/Validation?
Extend Respect’s `Rule` class or use closures: `v::custom(function($input) { return strlen($input) > 10; })`. In Laravel, register custom rules via `Validator::extend()` or use Respect’s `RuleSet` for reusable logic. Example: `v::rule(new CustomRule())->validate($input)`.
Does Respect/Validation work with Livewire or Inertia.js for client-side validation?
Yes, it’s ideal for server-side validation in Livewire/Inertia. Use the same rules in your backend (e.g., Form Requests) and mirror them in client-side libraries like VeeValidate. Respect’s chainable syntax maps cleanly to frontend validation frameworks, reducing duplication.
What are the alternatives to Respect/Validation for Laravel?
Laravel’s built-in `Validator` is the primary alternative, but Respect offers more composable rules (e.g., `numeric()->between()` vs. `between:1,255`). Other options include `laravel-validator` (Laravel-specific) or `symfony/validator` (heavier). Respect stands out for its lightweight, chainable API and PHP-first design.
How do I test validation logic in Laravel using Respect/Validation?
Use PHPUnit with Respect’s built-in testing utilities. Example: `$validator = new Validation(); $this->assertTrue($validator->email()->isValid('[email protected]'))`. For Laravel, test Form Requests with `assertValidationException()` or mock the `Validation` class in unit tests. The package’s TDD-friendly design accelerates validation testing.
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.
robertmarney/lara-hierarchial-collections
simonschaufi/rule-doc-generator
emissaoja/emissaoja
blackbricksoftware/gravityforms-civicrm-form-processor
al-rahabi/fancy-crud
jinas/dhivatar-component
mltstephane/laravel-quality
bernskiold/laravel-talentlms
bernskioldmedia/laravel-form-architect
youbar/easy-crud
c-point-labs/laravel-hostyourai
dbravoan/dbcms-admin-theme-dbcms
dbravoan/dbcms-theme-db-cyber
dbravoan/dbcms-blocks-basic
dbravoan/dbcms-module-content-audit
dbravoan/dbcms-module-ai-assistant
paygate-to/paygate-php
padosoft/askmydocs-connector-base
defstudio/supercharged-carbon
bernskioldmedia/laravel-matomo