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 Validate

Laravel Validate Laravel Package

milwad/laravel-validate

Enhanced Laravel validation with a large set of custom rule classes and helper methods for faster, cleaner advanced validation. Includes localization support and works with Laravel 9+ (PHP 8+), with community-contributed language packs.

View on GitHub
Deep Wiki
Context7

The Laravel-Validate package enhanced Laravel validation capabilities with custom rules and methods for simplified and efficient validation logic

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.
codifyo/ts-generator-bundle
andydefer/laravel-cluster
testo/fiber
mintobit/jobqueue
a4sex/maintenance-bundle
a4sex/entity-date-update
a4sex/client-identifier
a4sex/base-utilites
a4sex/key-value-storage
a4sex/micro-status
chilldev/dependency-injection-extra
datinglibre/datinglibre-app-api
biberltd/corebundle
bricre/symfony-bundle-test
biberltd/logbundle
dominium/http-adapter-bundle
dominium/google-analytics
a4sex/auto-clean-entity
christhompsontldr/laravel-inky
spatie/mailcoach-vapor