UNPKG

ec-validator-dni

Version:

Validation of Ecuadorian identification documents (ID card and RUC)

58 lines (53 loc) 2.06 kB
declare enum TypeIdentification { DNI = "DNI", RUC = "RUC", RUC_PERSON_NATURAL = "RUC_PERSON_NATURAL", RUC_SOCIETY_PRIVATE = "RUC_SOCIETY_PRIVATE", RUC_PUBLIC_SOCIETY = "RUC_PUBLIC_SOCIETY", POSSIBLY_VALID_RUC = "POSSIBLY_VALID_RUC" } interface Result { isValid: boolean; errorMessage?: string; } /** * Validates an Ecuadorian DNI (Cédula de Identidad) number. * @param {string} dni - The DNI number to validate * * @returns {Result} An object containing: * - isValid: boolean indicating if the DNI is valid * - errorMessage?: string with error details if validation fails */ declare const dniValidation: (dni: string) => Result; /** * Validates possibly a valid RUC (Registro Único de Contribuyentes). * * @param {string} ruc - The RUC to be validated. * * @returns {Result} An object containing: * - isValid: boolean indicating if the DNI is valid * - errorMessage?: string with error details if validation fails */ declare const isPossiblyValidRuc: (ruc: string) => Result; /** * Validates a RUC (Registro Único de Contribuyentes) based on its type. * * @param {string} ruc - The RUC to be validated. * @param {TypeIdentification} typeIdentification - The type of RUC to validate (e.g., natural person, private society, public society). * * @returns {Result} An object containing: * - isValid: boolean indicating if the DNI is valid * - errorMessage?: string with error details if validation fails */ declare const validateRucByType: (ruc: string, typeIdentification: TypeIdentification) => Result; /** * Validates a RUC (Registro Único de Contribuyentes) by checking all possible types. * * @param {string} ruc - The RUC to be validated. * * @returns {Result} An object containing: * - isValid: boolean indicating if the DNI is valid * - errorMessage?: string with error details if validation fails */ declare const validateRuc: (ruc: string) => Result; export { type Result, TypeIdentification, dniValidation, isPossiblyValidRuc, validateRuc, validateRucByType };