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+.
Architecture fit
Rule subclasses that implement ValidationRule, so it slots into FormRequests, Validator::make(), and inline $request->validate() calls without touching the framework's core validation pipeline.new ValidRule()) usage path — the integration surface is just composer require plus optional config/lang publishing. That keeps it at the "leaf" of our dependency graph with no event hooks, middleware, or DB side effects.using_container config flag (string-syntax rules like 'required|ValidPhone') does introduce container resolution into the validation path. Treat this as an opt-in convenience, not the default architecture — it trades explicitness for magic and complicates static analysis.required, email, unique, exists) which Laravel already handles with better tested coverage.Integration feasibility
composer require milwad/laravel-validate, optionally vendor:publish --tag="laravel-validate-config" and --tag="validate-lang-{locale}" for localized messages.Technical risk
ValidCreditCard, ValidIban, and ValidImei are regex-oriented. Some validation libraries perform Luhn/mod-97 checksum verification; a regex-only implementation will accept structurally valid but numerically invalid values. This is the single highest-impact risk for financial/PII fields and must be verified per rule before use in a compliance-sensitive path.using_container makes validation behavior dependent on class-resolution state, which can silently break in octane/queue/serialization contexts or under strict autoloading. Low probability, high debuggability cost.Key questions
using_container string syntax, and if so, what is our enforcement story for code review and static analysis?Stack fit
App\Rules\* alias (extends or wraps the package rule) so call sites reference our namespace, not the third-party one. This is the key architectural decision — it lets us swap or patch implementations without a repo-wide find-and-replace.Migration path
regex: and Rule implementations → identify overlaps with the catalog → replace those hand-rolled rules with wrapped package rules → delete the duplicate code.Compatibility
composer.lock and add a CI job that runs the full test suite on the lowest and highest supported Laravel versions.ValidationRule vs legacy Rule contract) — the package's minimum PHP 8.0 gives it room, but the 2.0 line should be treated as the only supported line going forward.Sequencing
ValidSlug, ValidPort, ValidIpAddressIPV4) behind wrappers in a single service; write negative-case tests for each.Maintenance
Support
Scaling
using_container mode, which adds container lookups per validation call. Avoid it on hot paths.Failure modes
| Failure | Symptom | Detection | Response |
|---|---|---|---|
| Pattern-only rule accepts invalid data | Bad data persisted (e.g., a non-Luhn card number passes) | Unit tests with negative fixtures; data-quality monitoring downstream | Replace with checksum implementation behind wrapper |
| Localization key missing | User sees package default or fallback language | Locale-specific test of message output | Publish and override lang file |
| Upstream major bump breaks rule | Validation exceptions or silent behavior change after composer update |
CI matrix on lowest/highest Laravel version | Pin, patch locally, or drop rule |
using_container resolution failure |
Rule silently not applied or class error | Integration test in queued/octane context | Disable container mode; use new syntax |
| Maintainer abandonment | No releases for a Laravel major | Release-cadence watch | Fork the handful of rules we use (MIT permits) |
The dominant failure mode is silent false acceptance, not a crash — which is why every adopted rule needs negative-case tests rather than trusting README examples.
Ramp-up
How can I help you explore Laravel packages today?