FiscalCodeValidator 1.0.0

Additional Details

Errors reading data files

There is a newer version of this package available.
See the version list below for details.
dotnet add package FiscalCodeValidator --version 1.0.0
NuGet\Install-Package FiscalCodeValidator -Version 1.0.0
This command is intended to be used within the Package Manager Console in Visual Studio, as it uses the NuGet module's version of Install-Package.
<PackageReference Include="FiscalCodeValidator" Version="1.0.0" />
For projects that support PackageReference, copy this XML node into the project file to reference the package.
paket add FiscalCodeValidator --version 1.0.0
#r "nuget: FiscalCodeValidator, 1.0.0"
#r directive can be used in F# Interactive and Polyglot Notebooks. Copy this into the interactive tool or source code of the script to reference the package.
// Install FiscalCodeValidator as a Cake Addin
#addin nuget:?package=FiscalCodeValidator&version=1.0.0

// Install FiscalCodeValidator as a Cake Tool
#tool nuget:?package=FiscalCodeValidator&version=1.0.0

FiscalCodeValidator

Fiscal Code Validator can be used to perform a syntactic validation of Italian fiscal codes.

FiscalCode

The FiscalCode class can be initialized by passing the complete fiscal code in the constructor. The code is decomposed into the constituent units (first name, last name, gender, birth date, and birth place). Each piece of information is individually extracted from the string and the class properties are populated. If the code provided is incorrect, some of the properties may be left null.

FiscalCode fiscalCode = new FiscalCode("RSSLRA90D70L378H");
string lastName = fiscalCode.LastName; // RSS
string firstName = fiscalCode.FirstName; // LRA
DateTime? date = fiscalCode.Date; // 1990-04-30
Gender? gender = fiscalCode.Gender; // Gender.Female
Place place = fiscalCode.Place; // Trento

Match

The FiscalCode class provides some methods to check if the fiscal code data partially corresponds to the owner’s personal information. It should be noted that these functions do not provide information on the overall validity of the code.

bool result = fiscalCode.matchLastName("Rossi"); // true
bool result = fiscalCode.matchFirstName("Laura"); // true
bool result = fiscalCode.matchGender(Gender.Male); // false
bool result = fiscalCode.matchDate(new DateTime(1990, 5, 30)); // false
bool result = fiscalCode.matchPlace(Utility.GetPlace("L378")); // true

Validity

The isValid() method performs a syntactic validation of each section of the code, individually. If no parameters are provided, the method checks if all the properties of the FiscalCode instance have been populated correctly and then verifies the validity of the check digit.

bool result = fiscalCode.isValid(); // true

If one or more parameters are provided, the method performs the former validation and then checks whether the data provided matches the code information.

bool result = fiscalCode.isValid(firstName: "Laura", gender: Gender.Female); // true
bool result = fiscalCode.isValid(gender: Gender.Male); // false

Notes

  1. The validation method considers the omocodia problem
  2. To verify the existence of a fiscal code you can use this service

Author

Michele Benolli, michele.benolli@gmail.com

Product Compatible and additional computed target framework versions.
.NET net5.0 is compatible.  net5.0-windows was computed.  net6.0 was computed.  net6.0-android was computed.  net6.0-ios was computed.  net6.0-maccatalyst was computed.  net6.0-macos was computed.  net6.0-tvos was computed.  net6.0-windows was computed.  net7.0 was computed.  net7.0-android was computed.  net7.0-ios was computed.  net7.0-maccatalyst was computed.  net7.0-macos was computed.  net7.0-tvos was computed.  net7.0-windows was computed.  net8.0 was computed.  net8.0-android was computed.  net8.0-browser was computed.  net8.0-ios was computed.  net8.0-maccatalyst was computed.  net8.0-macos was computed.  net8.0-tvos was computed.  net8.0-windows was computed. 
Compatible target framework(s)
Included target framework(s) (in package)
Learn more about Target Frameworks and .NET Standard.

NuGet packages

This package is not used by any NuGet packages.

GitHub repositories

This package is not used by any popular GitHub repositories.

Version Downloads Last updated
1.1.2 5,274 2/25/2023
1.1.1 3,201 1/17/2022
1.1.0 597 10/26/2021
1.0.0 556 10/20/2021