Laravel validator for italian fiscal code
You can install the package via composer:
composer require ivanomatteo/laravel-codice-fiscale
publish lang
php artisan vendor:publish --provider "IvanoMatteo\LaravelCodiceFiscale\LaravelCodiceFiscaleServiceProvider" --tag lang
php artisan vendor:publish --provider "IvanoMatteo\LaravelCodiceFiscale\LaravelCodiceFiscaleServiceProvider" --tag config
/*
Fiscal code fields name:
name
familyName
dateOfBirth
sex
cityCode
*/
$validated = Request::validate( [
// first parameter: the field containing the fiscal code
// second parameter: the corrisponding filed name for matching
'dob' => 'required|codfisc:fiscalCode,dateOfBirth',
'first_name' => 'required|codfisc:fiscalCode,name',
'last_name' => 'required|codfisc:fiscalCode,familyName',
//second parameter: can be omitted if the filed name is alredy correct
'sex' => 'required|codfisc:fiscalCode',
'cityCode' => 'required|codfisc:fiscalCode',
'fiscalCode' => 'required|codfisc',
]);
$validated = Request::validate( [
'first_name' => 'required',
'last_name' => 'required',
'dob' => 'required',
'sex' => 'required',
'cityCode' => 'required',
// all rules on fiscal code
'fiscalCode' => 'required|codfisc:first_name=name,last_name=familyName,dob=dateOfBirth,sex=sex,cityCode=cityCode',
]);
$validated = Request::validate( [
// ...
// just check the format
'fiscalCode' => 'required|codfisc',
]);
composer test
Please see CHANGELOG for more information what has changed recently.
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.
This package was generated using the Laravel Package Boilerplate.