PHPackages                             lloaldo/laravel-validate-spa - PHPackages - PHPackages  [Skip to content](#main-content)[PHPackages](/)[Directory](/)[Categories](/categories)[Trending](/trending)[Leaderboard](/leaderboard)[Changelog](/changelog)[Analyze](/analyze)[Collections](/collections)[Log in](/login)[Sign up](/register)

1. [Directory](/)
2. /
3. [Validation &amp; Sanitization](/categories/validation)
4. /
5. lloaldo/laravel-validate-spa

ActiveLibrary[Validation &amp; Sanitization](/categories/validation)

lloaldo/laravel-validate-spa
============================

Spanish Custom Validation Package for Laravel CIF, NIF, NIE, NSS, IBAN, Postal Code, Phone numbers, License plate...

2.0.1(10mo ago)07MITPHPPHP ^8.2.0|^8.3.0CI failing

Since Jun 19Pushed 10mo ago1 watchersCompare

[ Source](https://github.com/lloaldo/laravel-validate-spa)[ Packagist](https://packagist.org/packages/lloaldo/laravel-validate-spa)[ RSS](/packages/lloaldo-laravel-validate-spa/feed)WikiDiscussions main Synced 1mo ago

READMEChangelogDependencies (7)Versions (3)Used By (0)

Laravel Validate SPA
====================

[](#laravel-validate-spa)

A Laravel package that provides custom validation rules for Spanish identification numbers: NIF, NIE, CIF, SSN, IBAN, POSTAL CODE, PHONE, LICENSE PLATE, CCC, PASSPORT .

Features
--------

[](#features)

- Validates Spanish NIF (Documento Identificación Fiscal) and NIE (Número de Identidad de Extranjero).
- Validates Spanish CIF (Código de Identificación Fiscal).
- Validates Spanish SSN (Social Security Number).
- Validates Spanish IBAN (International Bank Account Number).
- Validates Postal Code Spanish.
- Validates Phone Number Spanish.
- Validates Spanish License plate vehicle(Vehículos Matrícula Española).
- Validates Spanish CCC(Old Spanish Bank Account, precursor of the IBAN).
- Validates Spanish Passport.
- Includes translatable error messages.
- Easy integration with Laravel's validation system.

Requirements
------------

[](#requirements)

- PHP &gt;= 8.0
- Laravel &gt;= 9.0

Installation
------------

[](#installation)

1. **Install the package via Composer**
    Run the following command in your Laravel project directory:

    ```
    composer require lloaldo/laravel-validate-spa
    ```
2. **Publish the language files (optional)**
    If you want to customize the validation error messages, publish the language files:

    ```
    php artisan vendor:publish --tag=lang
    ```

    This will copy the translation files to `resources/lang/vendor/laravel-validate-spa`. You can modify the messages in your desired language (e.g., `es/validation.php` for Spanish).
3. **Service Provider (optional for Laravel 9+)**
    The package uses Laravel's auto-discovery feature, so no manual registration is needed. If you're using an older version of Laravel without package discovery, add the service provider to `config/app.php`:

    ```
    'providers' => [
        // Other providers...
        Lloaldo\LaravelValidateSpa\ValidationServiceProvider::class,
    ],
    ```

Usage
-----

[](#usage)

### Validation Rules

[](#validation-rules)

This package provides two custom validation rules: `personal_id`, `tax_identifier`, `spanish_nif`, `spanish_nie`, `spanish_cif`, `spanish_ssn`,`spanish_iban`, `spanish_postal_code`, `spanish_phone`, `spanish_license_plate` `spanish_ccc`and `spanish_passport`. You can use them in your controllers, form requests, or anywhere Laravel's validator is supported.

#### Example in a Controller

[](#example-in-a-controller)

```
use Illuminate\Http\Request;

public function store(Request $request)
{
    $validated = $request->validate([
        'personal_id' => 'required|spanish_personal_id',    // NIF,NIE
        'tax_identifier' => 'required|spanish_tax_number',   // NIF, NIE, CIF
        'nif' => 'required|spanish_nif',
        'nie' => 'required|spanish_nie',
        'cif' => 'nullable|spanish_cif',
        'ssn' => 'required|spanish_ssn',
        'iban' => 'required|spanish_iban',
        'address_postal_code' => 'nullable|spanish_postal_code',
        'phone' => 'nullable|spanish_phone',
        'license_plate' => 'nullable|spanish_license_plate',
        'ccc' => 'nullable|spanish_ccc',
        'passport' => 'nullable|spanish_passport',
        'name' => 'required|string|max:255',
    ]);

    // Process validated data...
    return redirect()->back()->with('success', 'Data saved successfully!');
}
```

#### Example in a Form Request

[](#example-in-a-form-request)

```
namespace App\Http\Requests;

use Illuminate\Foundation\Http\FormRequest;

class StoreWorkerRequest extends FormRequest
{
    public function rules()
    {
        return [
            'personal_id' => 'required|spanish_personal_id',
            'cif' => 'nullable|spanish_cif',
            'ssn' => 'required|spanish_ssn',
            'iban' => 'required|spanish_iban',
            'name' => 'required|string|max:255',
        ];
    }
}
```

### Customizing Error Messages

[](#customizing-error-messages)

Error messages are loaded from the package's language files. After publishing the language files, you can edit them in `resources/lang/vendor/laravel-validate-spa/{lang}/validation.php`. For example:

```
// resources/lang/vendor/laravel-validate-spa/es/validation.php
return [
    'spanish_nif' => 'El :attribute no es un NIF válido.',
    'spanish_nie' => 'El :attribute no es un NIE válido.',
    'spanish_cif' => 'El :attribute no es un CIF válido.',
    'spanish_ssn' => 'El :attribute no es un Número de la Seguridad Social válido.',
    'spanish_iban' => 'El :attribute no es un IBAN español válido.',
    'spanish_postal_code' => 'El :attribute no es un código postal español válido.',
    'spanish_phone' => 'El :attribute no es un número de teléfono español válido.',
    'spanish_license_plate' => 'El :attribute no es una matrícula española válida.',
    'spanish_ccc' => 'El :attribute no es un CCC español válido.',
    'spanish_passport' => 'El :attribute es un pasaporte español válido.',
];
```

If you don't publish the files, the package will use its default messages (if provided) or fall back to Laravel's generic "The :attribute is invalid" message.

### Testing the Rules

[](#testing-the-rules)

You can test the validation rules using Laravel's `Validator` facade in Tinker:

```
php artisan tinker
Validator::make(['nif' => 'XXXXXXZ'], ['nif' => 'spanish_nif'])->fails() // false (valid)
Validator::make(['nif' => 'XXXXXXA'], ['nif' => 'spanish_nif'])->fails() // true (invalid)
Validator::make(['cif' => 'AXXXXXX'], ['cif' => 'spanish_cif'])->fails() // false (valid)
Validator::make(['ssn' => 'XXXXXXXXXXXX'], ['ssn' => 'spanish_ssn'])->fails() // true (invalid)
Validator::make(['ssn' => 'XXXXXXXXXXXX'], ['ssn' => 'spanish_ssn'])->fails() // false (valid)
Validator::make(['iban' => 'ESXXXXXXXXXXXXX'], ['iban' => 'spanish_iban'])->fails() // false (valid)
Validator::make(['iban' => 'ESXXXXXXXXXXXXX'], ['iban' => 'spanish_iban'])->fails() // true (invalid)
Validator::make(['postal_code' => '08001'], ['postal_code' => 'spanish_postal_code'])->fails() // false (valid)
Validator::make(['postal_code' => '108001'], ['postal_code' => 'spanish_postal_code'])->fails() // false (invalid)
Validator::make(['phone' => 'XXXXXXXX'], ['phone' => 'spanish_phone'])->fails() // false (valid)
Validator::make(['license_plate' => 'XXXXABC'], ['license_plate' => 'spanish_license_plate'])->fails() // false (valid)
Validator::make(['ccc' => 'XXXX XXXX XX XXXXXXXXXX'], ['ccc' => 'spanish_ccc'])->fails() // false (valid)
Validator::make(['passport' => 'ABCXXXXXX'], ['ccc' => 'spanish_passport'])->fails() // false (valid)
```

Validation Logic
----------------

[](#validation-logic)

- **NIF/NIE**: Validates Spanish NIF (8 digits + letter) and NIE (X/Y/Z + 7 digits + letter) using the official algorithm.
- **CIF**: Validates Spanish CIF codes (letter + 7 digits + control character) according to the official rules.
- **SSN**: Validates Spanish Social Security Numbers (12 digits: 2 for province code, 8 sequential digits, and 2 control digits) by checking the province code (01-99) and verifying the control digits using the modulo 97 algorithm.
- **IBAN**: Validates Spanish IBANs (24 characters: "ES" + 2 control digits + 20-digit bank account number) using the ISO 7064 MOD 97-10 algorithm, ensuring the country code is "ES" and the control digits are correct.
- **POSTAL CODE** Validates Spanish Postal Code
- **PHONE** Validates Spanish Phone Number
- **VEHICLE LICENSE PLATE** Validates Spanish License Plate Car(vehículos Matrículas española)
- **CCC** Validates Spanish Old Spanish Bank Account, precursor of the IBAN
- **PASSPORT** Validates Spanish Passport

Contributing
------------

[](#contributing)

Contributions are welcome! Feel free to submit a pull request or open an issue on the [GitHub repository](https://github.com/lloaldo/laravel-validate-spa).

License
-------

[](#license)

This package is open-source software licensed under the [MIT License](LICENSE).

**Laravel Valida Spa** was created by **\[Domingo Albújar\]** under the **[MIT license](https://opensource.org/licenses/MIT)**.

###  Health Score

31

—

LowBetter than 68% of packages

Maintenance53

Moderate activity, may be stable

Popularity4

Limited adoption so far

Community7

Small or concentrated contributor base

Maturity52

Maturing project, gaining track record

 Bus Factor1

Top contributor holds 100% of commits — single point of failure

How is this calculated?**Maintenance (25%)** — Last commit recency, latest release date, and issue-to-star ratio. Uses a 2-year decay window.

**Popularity (30%)** — Total and monthly downloads, GitHub stars, and forks. Logarithmic scaling prevents top-heavy scores.

**Community (15%)** — Contributors, dependents, forks, watchers, and maintainers. Measures real ecosystem engagement.

**Maturity (30%)** — Project age, version count, PHP version support, and release stability.

###  Release Activity

Cadence

Every ~0 days

Total

2

Last Release

326d ago

### Community

Maintainers

![](https://www.gravatar.com/avatar/a0efab44d616962d657e28784e3a9f3f391d1c11bab7c40bb79a21380d191ff3?d=identicon)[lloaldo](/maintainers/lloaldo)

---

Top Contributors

[![lloaldo](https://avatars.githubusercontent.com/u/7478777?v=4)](https://github.com/lloaldo "lloaldo (3 commits)")

---

Tags

phppackagelaravel-validate-spa

###  Code Quality

TestsPHPUnit

Static AnalysisPHPStan, Rector

Code StyleLaravel Pint

Type Coverage Yes

### Embed Badge

![Health badge](/badges/lloaldo-laravel-validate-spa/health.svg)

```
[![Health](https://phpackages.com/badges/lloaldo-laravel-validate-spa/health.svg)](https://phpackages.com/packages/lloaldo-laravel-validate-spa)
```

###  Alternatives

[larastan/larastan

Larastan - Discover bugs in your code without running it. A phpstan/phpstan extension for Laravel

6.4k43.5M5.2k](/packages/larastan-larastan)[bensampo/laravel-enum

Simple, extensible and powerful enumeration implementation for Laravel.

2.0k15.9M104](/packages/bensampo-laravel-enum)[deligoez/tckimlikno

Turkish Identification Number Verification &amp; Validation Package for Laravel

2917.4k](/packages/deligoez-tckimlikno)

PHPackages © 2026

[Directory](/)[Categories](/categories)[Trending](/trending)[Changelog](/changelog)[Analyze](/analyze)
