UNPKG

mexican-utils

Version:

Library that handles validations for several Mexican related fields

66 lines (63 loc) 2.45 kB
declare const GENDERS: { readonly male: "H"; readonly female: "M"; }; type Gender = keyof typeof GENDERS; declare const STATES: { readonly aguascalientes: "AS"; readonly baja_california: "BC"; readonly baja_california_sur: "BS"; readonly campeche: "CC"; readonly chiapas: "CS"; readonly chihuahua: "CH"; readonly ciudad_de_méxico: "DF"; readonly coahuila_de_zaragoza: "CL"; readonly colima: "CM"; readonly durango: "DG"; readonly guanajuato: "GT"; readonly guerrero: "GR"; readonly hidalgo: "HG"; readonly jalisco: "JC"; readonlyxico: "MC"; readonly michoacán_de_ocampo: "MN"; readonly morelos: "MS"; readonly nayarit: "NT"; readonly nuevo_león: "NL"; readonly oaxaca: "OC"; readonly puebla: "PL"; readonly querétaro: "QT"; readonly quintana_roo: "QR"; readonly san_luis_potosí: "SP"; readonly sinaloa: "SL"; readonly sonora: "SR"; readonly tabasco: "TC"; readonly tamaulipas: "TS"; readonly tlaxcala: "TL"; readonly veracruz_de_ignacio_de_la_llave: "VZ"; readonly yucatán: "YN"; readonly zacatecas: "ZS"; readonly no_especificado: "NE"; }; type State = keyof typeof STATES; /** * Creates a CURP (Clave Única de Registro de Población) based on the provided * personal information and birth date. * The CURP format follows specific rules regarding the arrangement of * letters and numbers based on the person's names, birth date, gender, and state. * @param {string} name The full name. * @param {string} paternalSurname The first surname (last name). * @param {Gender} gender The gender. * @param {State} state The state code. * @param {string | number | Date} birthDate The date of birth in YYYY-MM-DD format. * @param {string} [maternalSurname=""] The second surname (last name). * @returns {string} The generated CURP string. * @throws {Error} Throws an error if the date of birth has an incorrect format. */ declare const createCURP: (name: string, paternalSurname: string, gender: Gender, state: State, birthDate: string | number | Date, maternalSurname?: string) => string; /** * Validates a given CURP (Clave Única de Registro de Población). * @param {string} curp The CURP string to validate. * @returns {boolean} Returns true if the CURP is valid, otherwise false. */ declare const validateCURP: (curp: string) => boolean; export { type State, createCURP, validateCURP };