Download the PHP package sevada/nie-validator without Composer
On this page you can find all versions of the php package sevada/nie-validator. It is possible to download/install these versions without Composer. Possible dependencies are resolved automatically.
Download sevada/nie-validator
More information about sevada/nie-validator
Files in sevada/nie-validator
Package nie-validator
Short Description Laravel validation rule for Spanish NIE (Número de Identidad de Extranjero) numbers
License MIT
Homepage https://github.com/sevada/nie-validator
Informations about the package nie-validator
Laravel NIF (NIE/DNI) Validator
A robust Laravel validation package for Spanish identification numbers:
- NIE (Número de Identidad de Extranjero)
- DNI (Documento Nacional de Identidad)
Validates according to the official algorithm regulated by Real Decreto 1553/2005, Artículo 11.
Features
✅ Combined Support - Validates both NIE and DNI numbers
✅ Accurate Validation - Implements official Spanish algorithms
✅ Flexible Input - Accepts various formats (spaces, hyphens, mixed case)
✅ Laravel Integration - Seamless integration with Laravel's validator
✅ Multilingual - Built-in English and Spanish error messages
✅ Type Safe - Strict type declarations throughout
✅ Well Tested - 100+ test cases with comprehensive coverage
✅ Zero Dependencies - No external dependencies beyond Laravel
Requirements
- PHP 8.2 or higher
- Laravel 10.x, 11.x, or 12.x
Installation
Install via Composer:
The service provider will be automatically registered.
Publishing Configuration (Optional)
Publish the configuration file:
Publish translation files:
Usage
Basic Validation
Use the nie or dni validation rules in your validation logic:
Using Rule Classes
You can also use the rule classes directly:
Accepted Formats
The validator automatically normalizes input and accepts various formats:
NIE Examples:
DNI Examples:
Configuration
The default configuration (config/nif.php):
Translations
English (Default)
Spanish
To use Spanish translations, set your application locale:
Testing
Run the test suite:
Security
This package validates mathematical format but does not verify authenticity with official databases. See SECURITY.md.
Important: Handle national ID numbers as sensitive personal data (GDPR).
License
The MIT License (MIT). Please see LICENSE for more information.