Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
4 changes: 4 additions & 0 deletions src/codice-fiscale.js
Original file line number Diff line number Diff line change
@@ -1,6 +1,8 @@
import { Comune } from './comune'
import { CHECK_CODE_CHARS, CHECK_CODE_EVEN, CHECK_CODE_ODD, MONTH_CODES, NUMERIC_POS, OMOCODIA_TABLE, OMOCODIA_TABLE_INVERSE } from './constants'
import { extractConsonants, extractVowels, getValidDate, birthplaceFields, getAllSubsets } from './utils'
import { COMUNI_LIST } from './lista-comuni'
import { PROVINCE } from './lista-province'

class CodiceFiscale {
get day () {
Expand Down Expand Up @@ -250,4 +252,6 @@ class CodiceFiscale {
CodiceFiscale.utils = {
birthplaceFields: birthplaceFields
}
CodiceFiscale.COMUNI = COMUNI_LIST
CodiceFiscale.PROVINCE = PROVINCE
module.exports = CodiceFiscale;
8 changes: 8 additions & 0 deletions src/lista-comuni.js
Original file line number Diff line number Diff line change
Expand Up @@ -13655,3 +13655,11 @@ export const COMUNI = [ ["A001","PD","ABANO BAGNI",0],
["M205","MI","ZUNICO",0],
["M206","CA","ZURI",0],
]

// Export a more user-friendly structure for external consumption
export const COMUNI_LIST = COMUNI.map(([cc, prov, nome, active]) => ({
belfioreCode: cc,
province: prov,
name: nome,
active: active === 1
}))
16 changes: 16 additions & 0 deletions types/codice-fiscale.d.ts
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,17 @@ import { birthplaceFields } from "./utils";

export type Gender = "F" | "M";

export interface IComuneData {
belfioreCode: string;
province: string;
name: string;
active: boolean;
}

export interface IProvinceData {
[key: string]: string;
}

export interface ICodiceFiscaleObject {
name: string;
surname: string;
Expand All @@ -26,6 +37,8 @@ declare class CodiceFiscale {
static utils: {
birthplaceFields: typeof birthplaceFields;
};
static COMUNI: IComuneData[];
static PROVINCE: IProvinceData;
birthday: Date;
birthplace: Comune;
name: string;
Expand Down Expand Up @@ -55,3 +68,6 @@ declare class CodiceFiscale {
}

export default CodiceFiscale;
export { CodiceFiscale };
export const COMUNI: IComuneData[];
export const PROVINCE: IProvinceData;