A set of validation rules specific to validate Mexico's CURP.
It requires Laravel >= 5 and PHP >= 7.2.
composer require pollin14/laravel-curp-validation
If you are using Laravel >= 6 and PHP >= 7.3 then you can install
composer require illuminatech/validation-composite
and use CurpRule
.
<?php
use Illuminate\Contracts\Validation\Factory;
use Pollin14\LaravelCurpValidation\Rules\CurpRule;
$validator = app(Factory::class)->make(
['curp' => 'ABCD123456HABCDEF01'],
['curp' => ['required', new CurpRule()]]
);
Of course, you can use the validations rules individuality
<?php
use Illuminate\Contracts\Validation\Factory;
use Pollin14\LaravelCurpValidation\Rules\CurpBirthdate;
use Pollin14\LaravelCurpValidation\Rules\CurpGender;
use Pollin14\LaravelCurpValidation\Rules\CurpLastConsonants;
use Pollin14\LaravelCurpValidation\Rules\CurpLastDigit;
use Pollin14\LaravelCurpValidation\Rules\CurpLength;
use Pollin14\LaravelCurpValidation\Rules\CurpPenultimateChar;
use Pollin14\LaravelCurpValidation\Rules\CurpStartWithFourLetters;
use Pollin14\LaravelCurpValidation\Rules\CurpState;
$rules = [
'curp_length',
'curp_date',
'curp_gender',
'curp_start_with_4_letters',
'curp_last_digit',
'curp_penultimate_char',
'curp_state',
'curp_birthdate'
];
// Or if you are using Lumen
$rules = [
new CurpLength(),
new CurpGender(),
new CurpStartWithFourLetters(),
new CurpLastDigit(),
new CurpPenultimateChar(),
new CurpState(),
new CurpBirthdate(),
new CurpLastConsonants(),
]
$validator = app(Factory::class)->make(
['curp' => 'ABCD123456HABCDEF01'],
['curp' => $rules]
);
Run the tests with:
vendor/bin/phpunit
Please see CONTRIBUTING for details.
If you discover any security-related issues, please email [email protected] instead of using the issue tracker.
The MIT License (MIT). Please see License File for more information.