- How do I install Intervention/Validation in a Laravel 12 project?
- Run `composer require intervention/validation`—the package auto-discovers and integrates with Laravel’s validation system without manual configuration. No additional setup is required for basic usage, and it works alongside Laravel’s built-in `Validator` facade.
- Which Laravel versions and PHP versions does this package support?
- Intervention/Validation supports Laravel 10–13 and PHP 8.1–8.5. It’s explicitly tested for PHP 8.5 and maintains backward compatibility with older Laravel versions. No additional dependencies or polyfills are needed.
- Can I use the new VIN validation rule for vehicle registration systems?
- Yes, the `Vin` rule validates Vehicle Identification Numbers with region-specific checks (e.g., `Vin::region(['US', 'EU'])`). It’s ideal for automotive apps, transportation platforms, or inventory systems requiring VIN validation. Error messages are customizable via Laravel’s language files.
- How do I customize error messages for rules like `iso-3166` or `currency-code`?
- Add custom messages to `/resources/lang/<language>/validation.php` under keys like `iso_3166` or `currency_code`. For example, `'iso_3166' => 'Please enter a valid country code.'`. You can also override messages dynamically in your validator using `->setCustomMessages()`.
- Will this package conflict with existing Laravel validation logic?
- No, the package integrates seamlessly with Laravel’s validation pipeline (Symfony Validator under the hood). New rules are additive only—no breaking changes to existing functionality. Rules like `iso-3166` or `currency-code` can coexist with custom regex or third-party packages, though package rules take precedence.
- How do I test the `vin` rule for edge cases like expired or malformed VINs?
- Use Laravel’s built-in testing tools to validate VINs with edge cases. For example, `Validator::make(['vin' => '1HGCM82633A123456'], ['vin' => 'required|vin'])->fails()` checks for invalid formats. Test both false positives (e.g., technically valid but expired VINs) and negatives (malformed inputs).
- Can I use these rules in Laravel FormRequests or API Resources?
- Absolutely. The package works natively with Laravel’s `FormRequest` validation and API Resources. For example, in a `StoreVehicleRequest`, you can use `'vin' => 'required|vin'` just like built-in rules. Rules also support chaining (e.g., `'required|iso-3166|country:US'`).
- Are there performance concerns with complex rules like `vin` in bulk processing?
- Rules like `vin` may introduce micro-latency due to regex or algorithmic checks. For high-throughput scenarios (e.g., bulk vehicle imports), benchmark performance and consider caching repeated validations or offloading to Laravel Queues for asynchronous processing.
- What’s the best way to migrate from custom validation logic to this package?
- Audit your existing validation logic for redundant rules (e.g., custom VIN or ISO-3166 checks) and replace them incrementally. Start with high-impact rules (e.g., `vin` for automotive apps) and phase out custom implementations. Use Laravel’s `ExtendableValidator` to integrate new rules into your pipeline.
- Are there alternatives to this package for specific rules like IBAN or credit card validation?
- While alternatives exist (e.g., `league/iso3166` for country codes or `bacon/bacon-qr-code` for QR validation), Intervention/Validation consolidates 37+ rules—including IBAN, BIC, ISBN, and credit cards—into a single, Laravel-native package. It’s ideal for projects needing multiple domain-specific validations without managing multiple dependencies.