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

Validation Laravel Package

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.

View on GitHub
Deep Wiki
Context7

The most awesome validation engine ever created for PHP

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('test@example.com'))`. 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.
anousss007/vigilance
supportpal/eloquent-model
ardenexal/fhir-models
laravel-at/laravel-image-sanitize
romalytar/yammi-audit-log-laravel
ardenexal/fhir-validation
arshaviras/weather-widget
laravel-chronicle/core
sunchayn/nimbus
daikazu/eloquent-salesforce-objects
unseen-codes/chat
romalytar/yammi-jobs-monitoring-laravel
kisame76/filament-db-table-state
nqxcode/laravel-lucene-search
dpfx/laravel-livewire-wizards
workos/workos-php-laravel
sofa/laravel-global-scope
nawasara/auth-primitives
adhocrat-io/arkhe-main
make-dev/orca-harpoon