Skip to content

Lightweight module for validate and decrypt Italian Tax Code (alias Codice Fiscale)

License

Notifications You must be signed in to change notification settings

stefanodotit/awesome-codice-fiscale

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

5 Commits
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 

Repository files navigation

awesome-codice-fiscale

Lightweight module for validate and decrypt Italian Tax Code (alias Codice Fiscale).
💣 Vanilla Javascript - No dependencies 💣

Installation

npm i awesome-codice-fiscale --save

How to use

Check if Codice Fiscale is valid

import { isValid } from 'awesome-codice-fiscale'
isValid(CODICE_FISCALE)

@return Boolean

Extract data from Codice Fiscale

import { extractInfo } from 'awesome-codice-fiscale'
const info = extractInfo(CODICE_FISCALE)

@return

{
    name: 'XXX', // String{3}: only 3 character
    surname: 'RSS', // String{3}: only 3 character
    birthYear: [XXNN, YYNN], // Array<Number>: 1 or 2 years (4 digit) [Codice Fiscale gave me only the last 2 numbers of birthday Year. So the person can have 1 years old or 101 years old]
    birthMonth: 11, // Number: month of birthday
    birthDay: 9, // Number: day of birthday
    sex: 'm', // String{1}: m => male || f => female
    birthPlace: 'XXXXX' // String: name of birth place
}

Check if user is adult

@input CODICE_FISCALE, AGE (default 18)

import { isAdult } from 'awesome-codice-fiscale'
isAdult(CODICE_FISCALE, 21)

@return Boolean (Also false when multiple birthYear and one of this is under age)

Available yarn scripts:

  • yarn run build: build the bundle into dist directory.
  • yarn run test: launch the tests.

About

Lightweight module for validate and decrypt Italian Tax Code (alias Codice Fiscale)

Resources

License

Stars

Watchers

Forks

Releases

No releases published

Packages

No packages published