Skip to content

ades4827/laravel-codice-fiscale

 
 

Repository files navigation

Laravel Fiscal Code Validator

Latest Version on Packagist Total Downloads

Laravel validator for italian fiscal code

Installation

You can install the package via composer:

composer require ivanomatteo/laravel-codice-fiscale

Usage

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',
]);

Testing

composer test

Changelog

Please see CHANGELOG for more information what has changed recently.

Contributing

Please see CONTRIBUTING for details.

Security

If you discover any security related issues, please email [email protected] instead of using the issue tracker.

Credits

License

The MIT License (MIT). Please see License File for more information.

Laravel Package Boilerplate

This package was generated using the Laravel Package Boilerplate.

About

Laravel validator for italian fiscal code

Resources

License

Stars

Watchers

Forks

Packages

No packages published

Languages

  • PHP 100.0%