https://github.com/orumad/laravel-spanish-validator
Laravel validator for spanish stuff: NIF, NIE, CIF, NSS, IBAN, Postal Code, Phone numbers
https://github.com/orumad/laravel-spanish-validator
cif iban identity-number laravel nie nss phone-number postal-codes spanish-phone spanish-postal tax-number validation validator
Last synced: 9 months ago
JSON representation
Laravel validator for spanish stuff: NIF, NIE, CIF, NSS, IBAN, Postal Code, Phone numbers
- Host: GitHub
- URL: https://github.com/orumad/laravel-spanish-validator
- Owner: orumad
- License: mit
- Created: 2019-05-03T14:33:27.000Z (about 7 years ago)
- Default Branch: main
- Last Pushed: 2024-08-23T11:39:09.000Z (almost 2 years ago)
- Last Synced: 2025-06-06T06:30:26.373Z (12 months ago)
- Topics: cif, iban, identity-number, laravel, nie, nss, phone-number, postal-codes, spanish-phone, spanish-postal, tax-number, validation, validator
- Language: PHP
- Homepage:
- Size: 36.1 KB
- Stars: 25
- Watchers: 2
- Forks: 15
- Open Issues: 1
-
Metadata Files:
- Readme: README.md
- Changelog: CHANGELOG.md
- Contributing: CONTRIBUTING.md
- License: LICENSE.md
Awesome Lists containing this project
README
# Laravel validator for spanish stuff: NIF, NIE, CIF, NSS, IBAN, Postal Code, Phone numbers
[](https://packagist.org/packages/orumad/laravel-spanish-validator)
[](https://github.styleci.io/repos/184770182)
[](https://scrutinizer-ci.com/g/orumad/laravel-spanish-validator)
[](https://packagist.org/packages/orumad/laravel-spanish-validator)
This package is a set of diferent validation rules for spanish national id numbers like:
- **NIF**: _"Número de Identificación Fiscal"_ (tax number for individuals).
- **NIE**: _"Número de Idenfiticación para Extranjeros"_ (identity number for foreigners).
- **CIF**: _"Código de Identificación Fiscal"_ (tax number for companies).
- **NSS**: _"Número de la Seguridad Social"_ (national security number).
Also the package include validators for:
- **IBAN**: International Bank Account Number.
- **Postal codes**: Spanish postal codes.
- **Phone number**: Spanish phone numbers format.
## Instalation
The package can be installed via composer:
```bash
composer require orumad/laravel-spanish-validator
```
The package will automatically register itself.
If you want to edit the validation messages, you should run the following command to publish the translation files into your `resources/lang` folder:
```bash
php artisan vendor:publish --provider="Orumad\SpanishValidator\SpanishValidatorServiceProvider"
```
## Available rules
- [`nif`](#nif)
- [`nie`](#nie)
- [`cif`](#cif)
- [`spanish_tax_number`](#spanish_tax_number)
- [`spanish_personal_id`](#spanish_personal_id)
- [`nss`](#nss)
- [`iban`](#iban)
- [`spanish_postal_code`](#spanish_postal_code)
- [`spanish_phone`](#spanish_phone)
### `nif`
Determine if the input is a valid _"Número de Identificación Fiscal"_ (tax number for individuals).
### `nie`
Determine if the field under validation is a valid _"Número de Idenfiticación para Extranjeros"_ (identity number for foreigners).
### `cif`
This rule will validate if the input field is a valid _"Código de Identificación Fiscal"_ (tax number for companies).
### `spanish_tax_number`
This rule validates if the input is a valid spanish tax number: NIF or NIE or CIF.
### `spanish_personal_id`
Will validate if the input is a valid personal id number in Spain (NIF or NIE).
### `nss`
Determine if the field under validation is a valid "Número de la Seguridad Social"_ (national security number).
### `iban`
Test if the input field is a valid IBAN bank account number. _(This uses the package `globalcitizen/php-iban` to check the validity of IBAN)_
### `spanish_postal_code`
Will check if the postal code is a valid spanish postal code.
### `spanish_phone`
This tule validates if the input field content is a valid spanish phone number format.
### Testing
``` bash
composer test
```
### Changelog
Please see [CHANGELOG](CHANGELOG.md) for more information on what has changed recently.
## Contributing
Please see [CONTRIBUTING](CONTRIBUTING.md) for details.
### Security
If you discover any security related issues, please email dev@danielmunoz.io instead of using the issue tracker.
## License
The MIT License (MIT). Please see [License File](LICENSE.md) for more information.