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 Validate

Laravel Validate Laravel Package

milwad/laravel-validate

Laravel Validate extends Laravel's built-in validation with a large collection of custom rule classes and helper methods, making advanced validation logic simpler and faster to write. Includes localization support and requires PHP 8.0+ and Laravel 9.0+.

View on GitHub
Deep Wiki
Context7

Laravel Validate extends Laravel's validation layer with a large collection of ready-made custom rule classes, so complex validation logic can be expressed faster and more readably than with closures or inline conditionals. It ships with localization support for many languages, letting error messages match your application's locale, and requires PHP >= 8.0 with Laravel >= 9.0.

  • Dozens of ready-to-use validation rule classes
  • Multilingual error messages via localization
  • Simple, expressive syntax for advanced validation
  • Installable in seconds with Composer
  • Actively maintained with automated test and quality checks
Frequently asked questions about Laravel Validate
How do I install and set up milwad/laravel-validate in a Laravel 11 project?
Run `composer require milwad/laravel-validate` to install. No additional setup is required for basic usage—just use rules like `ValidPhoneNumber` directly in your Form Requests or validation arrays. For container integration, add `'using_container' => true` to the config and resolve rules via the service container.
Does this package work with Laravel’s built-in Form Request validation?
Yes, it integrates seamlessly. Replace or extend your `rules()` method in Form Requests with package rules (e.g., `'phone' => ['required', 'ValidPhoneNumber']`). The package leverages Laravel’s native `Validator` facade, so no changes to your existing validation logic are needed.
Can I use these rules in API validation (e.g., Laravel Sanctum or Passport)?
Absolutely. Use the rules in your API resource validation or directly in controller methods with `Validator::make()`. For example, `Validator::make($data, ['credit_card' => ['required', 'ValidCreditCard']])` works identically to Form Requests.
What Laravel and PHP versions are supported?
The package supports Laravel 9 through 13 and PHP 8.0+. Check the [compatibility table](https://github.com/milwad-dev/laravel-validate#requirements) for version-specific notes. Upgrades between Laravel 9–13 are backward-compatible with no breaking changes.
How do I add custom validation rules or extend existing ones?
Extend the package’s `Rule` classes (e.g., `ValidPhoneNumber`) by creating your own class and overriding methods like `passes()`. Place it in `app/Rules` and reference it in your validation logic. The package’s OOP design makes this straightforward.
Are there any performance concerns with using this package?
Minimal overhead exists if you enable `using_container: true`, as it resolves rules dynamically. For high-throughput APIs, benchmark with `using_container: false` (static rules) to compare speeds. The package avoids heavy dependencies, so impact is typically negligible.
Does this package support localization for validation messages?
Yes, it includes built-in localization for multiple languages (e.g., English, Persian). Unsupported languages can be added via [GitHub PRs](https://github.com/milwad-dev/laravel-validate/pulls). Messages follow Laravel’s localization conventions, so they integrate with your existing `lang/validation.php` files.
What happens if a rule like ValidJwt or ValidIban requires external libraries (e.g., firebase/php-jwt)?
Some rules depend on third-party libraries (e.g., `ValidJwt` needs `firebase/php-jwt`). These must be installed separately via Composer. The package documents dependencies in its [README](https://github.com/milwad-dev/laravel-validate#requirements), so check before use.
How do I test validation rules in my Laravel application?
Test rules like any Laravel validation logic. Use PHPUnit to assert `Validator::make($data, ['field' => 'ValidRule'])->fails()` or `passes()`. For edge cases (e.g., false positives in `ValidCreditCard`), write custom tests or extend the rule’s logic to handle exceptions.
Are there alternatives to this package for Laravel validation?
Yes, consider Laravel’s native `Rule` objects (e.g., `Rule::required()->ValidPhoneNumber()`) for fluent chaining, or packages like `spatie/laravel-validation-rules` for additional rules. This package distinguishes itself with localization support, region-specific rules (e.g., `ValidIranPostalCode`), and seamless Laravel integration.
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.
elmogy/larafast
xeviant/laravel-paystack
gorilladash/laravel-website-sdk
martialbe/flysystem-oss
chondal/3312client
jeroen-g/flickr
opscale-co/nova-genbi
itsjustvita/laravel-retention
tequilarapido/trackit
gregsphotography/site-builder-filament
cabaoctavio/laravel-query-log
gregsphotography/site-builder-components
io-digital/clickatell
snowsoft/laravel-admin
oxygen/auth
relicsoftware/barakah-payment-gateway
tobya/work-with-composer
equipc/laravel-email-validator
equipc/laravel-email-database-log
adedsec/nova-translated-labels