ivanomatteo/laravel-codice-fiscale

Laravel validator for italian fiscal code

0.1.11 2022-12-12 12:33 UTC

This package is auto-updated.

Last update: 2024-10-12 16:27:13 UTC


README

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 ivanomatteo@gmail.com 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.