joepc74/laravel-spanish-validator
Laravel package that provides Spanish-language validation messages for Laravel’s validator, helping you localize form errors quickly. Drop in, configure the locale, and use standard Laravel validation rules with Spanish responses.
Validator::extend() or custom rules). It doesn’t introduce new architectural layers (e.g., ORM, caching, or event-driven components), reducing coupling.Validator facade and rule system, requiring minimal boilerplate. Example:
$validator = Validator::make($request->all(), [
'nif' => 'required|spanish_nif',
'phone' => 'required|spanish_phone',
]);
AppServiceProvider or per-route/controller, adhering to Laravel’s modularity.Validator::extend() in PHPUnit).AppServiceProvider::boot():
Validator::extend('spanish_nif', function ($attribute, $value, $parameters) {
return (new SpanishNifValidator)->validate($value);
});
resources/lang/es/validation.php).spanish_phone vs. spanish_mobile).composer.json constraints). If using an older version (e.g., 7.x), ensure no breaking changes.php config). No major compatibility risks.User::create($validatedData)).StoreUserRequest) or API controllers before business logic.return response()->json(['error' => 'Invalid NIF'], 422)).composer update + testing.The nif spanish_nif must be valid). Use Laravel’s Validator facade to inspect rules.Log::error("Invalid NIF: $nif")).| Failure Scenario | Impact | Mitigation |
|---|---|---|
| Invalid NIF/NIE submitted | Rejected user registration | Clear error messages + user guidance. |
| IBAN validation fails | Payment processing errors | Fallback to manual review or external API. |
| Phone number format mismatch | SMS/OTP delivery failures | Log and alert on repeated failures. |
| Package update breaks rules | Validation regressions | Test in staging before production updates. |
| Regional postal code variations | Invalid addresses in Spain | Extend package or add custom rules. |
spanish_nif).spanish_phone vs. spanish_mobile").VALIDATION.md or wiki.How can I help you explore Laravel packages today?