UNPKG

tcra-num-check

Version:

Tanzanian number validator with reference to the national numbering plan and signaling point code plan

120 lines 3.66 kB
import { NumberValidationResult, NumberType, ValidationOptions, NumberFormatOptions, NumberingPlanQuery, NumberingPlanStatistics, ValidatorMode, ValidatorFeatures, ValidatorConfig } from "./types"; /** * TCRA Number Validator * Validates Tanzanian phone numbers according to the national numbering plan * Comprehensive implementation covering all aspects of the numbering plan * Supports multiple modes: basic, full, and custom */ export declare class TCRANumberValidator { private numberingPlan; private mode; private features; constructor(config?: ValidatorConfig); /** * Set the validator mode * @param mode - The mode to set * @param features - Optional features to override */ setMode(mode: ValidatorMode, features?: Partial<ValidatorFeatures>): void; /** * Get the current mode */ getMode(): ValidatorMode; /** * Get the current features configuration */ getFeatures(): ValidatorFeatures; /** * Update specific features * @param features - Features to update */ updateFeatures(features: Partial<ValidatorFeatures>): void; /** * Validates a Tanzanian phone number * @param phoneNumber - The phone number to validate * @param options - Validation options * @returns Validation result with details */ validate(phoneNumber: string, options?: ValidationOptions): NumberValidationResult; /** * Get effective features combining class features with per-call overrides */ private getEffectiveFeatures; /** * Cleans a phone number by removing non-digit characters */ private cleanNumber; /** * Checks if the number format is valid */ private isValidFormat; /** * Extracts number parts (country code, national prefix, subscriber number) */ private extractNumberParts; /** * Validates the number type and determines operator */ private validateNumberType; /** * Gets operator name by prefix */ private getOperatorByPrefix; /** * Gets operator alias by prefix **/ private getOperatorAlias; /** * Gets region by prefix */ private getRegionByPrefix; /** * Gets emergency service by code */ private getEmergencyService; /** * Gets portability status for number type */ private getPortabilityStatus; /** * Validates signaling point code */ private validateSignalingPointCode; /** * Formats a valid number to international format */ formatInternational(phoneNumber: string): string | null; /** * Formats a valid number to national format */ formatNational(phoneNumber: string): string | null; /** * Formats a number with various options */ formatNumber(phoneNumber: string, options: NumberFormatOptions): string | null; /** * Queries the numbering plan for specific criteria */ queryNumberingPlan(query: NumberingPlanQuery): any[]; /** * Gets numbering plan statistics */ getNumberingPlanStatistics(): NumberingPlanStatistics; /** * Validates carrier selection code */ validateCarrierSelection(carrierCode: string): boolean; /** * Checks if number portability is supported for a number type */ isNumberPortabilitySupported(numberType: NumberType): boolean; /** * Gets all signaling point codes for an operator */ getSignalingPointCodes(operator?: string): any[]; /** * Gets emergency services */ getEmergencyServices(): any[]; } //# sourceMappingURL=validator.d.ts.map