- How do I install ajgl/validator-es in a Laravel application?
- Install it with Composer using composer require ajgl/validator-es. The package is framework-agnostic and does not require a Laravel service provider. Composer autoloading makes the validator classes available, and you can instantiate them inside a custom rule or service. Confirm your application's PHP version meets the package requirement before adopting it.
- Does ajgl/validator-es provide Laravel validation rules out of the box?
- No. It exposes a simple ValidatorInterface with an isValid method and returns a boolean. Laravel integration requires a thin wrapper such as a custom Rule object, a closure rule, or a service-layer call. You also own the validation messages and test coverage for the wrapper.
- Which Spanish codes can ajgl/validator-es validate?
- The library validates Spanish DNI, NIE, IdCard, CCC, and Spanish IBAN codes. IdCard covers either DNI or NIE. Validation is based on format and checksum rules for those identifiers, not on government or banking records.
- What PHP and Laravel versions does ajgl/validator-es support?
- The package requires PHP 8.0 or later based on changelog signals, and its changelog also shows Symfony 7 and PHP 8.3 support signals. Laravel-specific compatibility should be verified in your target application. The package has no hard dependencies, which reduces conflict risk.
- How do I create a Laravel custom rule for Spanish DNI or NIE with this package?
- Create a class that implements Laravel's ValidationRule contract, instantiate the appropriate validator such as IdCardValidator or NieValidator, and call isValid on the input value. If validation fails, return a Laravel validation failure with a clear Spanish identifier message. Use one rule class per code type and register it in your form request rules.
- Does ajgl/validator-es verify that a Spanish ID or bank account actually exists?
- No. It validates format and checksum only. It does not confirm that a DNI or NIE is active in government systems or that a Spanish IBAN belongs to a real bank account. Real-time identity or bank-account verification requires an external verification service.
- Is ajgl/validator-es safe to use in production Laravel applications?
- The runtime risk is low because the library is stateless, small, and MIT licensed. However, the repository has minimal adoption and no visible PHPUnit suite in the provided materials, so treat it as a buy-small, wrap-tightly dependency. Own the Laravel wrapper, error messages, and regression tests, and monitor validation failures for false positives or negatives.
- How should I test Spanish DNI, NIE, CCC, and IBAN validation in Laravel?
- Add unit tests for known-good and known-bad Spanish identifiers for each code type, including invalid checksums and edge cases. Test the Laravel rule wrapper to confirm it returns the expected validation failures and messages. Run these tests in your own CI so upstream changes cannot silently break validation behavior.
- Can I use ajgl/validator-es outside Laravel or in a service layer?
- Yes. It is a plain PHP library, so you can instantiate a validator and call isValid in imports, background jobs, API payloads, or other non-request workflows. For Laravel applications, keep custom validation rules as the primary request-validation integration point and use a service wrapper for non-request validation.
- What are alternatives to ajgl/validator-es for Spanish DNI, NIE, and IBAN validation in Laravel?
- Evaluate whether existing Laravel or Symfony validation constraints can cover your required Spanish code checks without a new dependency. You can also implement custom regex and checksum logic, especially if you need only a subset such as DNI or NIE. Because ajgl/validator-es has a small surface area, forking or replacing it later is feasible if upstream maintenance stalls.