PHP code example of sevada / nie-validator

1. Go to this page and download the library: Download sevada/nie-validator library. Choose the download type require.

2. Extract the ZIP file and open the index.php.

3. Add this code to the index.php.
    
        
<?php
require_once('vendor/autoload.php');

/* Start to develop here. Best regards https://php-download.com/ */

    

sevada / nie-validator example snippets


use Illuminate\Http\Request;

public function store(Request $request)
{
    $validated = $request->validate([
        'nie_number' => ['

use Sevada\NifValidator\Rules\Nie;
use Sevada\NifValidator\Rules\Dni;

$request->validate([
    'nie_number' => ['

'X1234567L'      // ✅ Standard format
'Y-1234567-X'    // ✅ With hyphens
'Z 1234567 R'    // ✅ With spaces

'12345678Z'      // ✅ Standard format
'12345678-Z'     // ✅ With hyphens
'12345678 Z'     // ✅ With spaces

return [
    // Official control letter sequence (DO NOT MODIFY)
    'control_letters' => str_split('TRWAGMYFPDXBNJZSQVHLCKE'),
    
    // Validation strictness
    'strict_format' => false, // Allow spaces and hyphens
];

app()->setLocale('es');
bash
php artisan vendor:publish --tag=nif-config
bash
php artisan vendor:publish --tag=nif-translations