UNPKG

advanced-ussd-builder

Version:

Advanced USSD Menu Builder with persistent state and navigation

81 lines 2.77 kB
export declare class InputValidator { private static readonly SAFE_USSD_REGEX; private static readonly E164_REGEX; private static readonly LOCAL_PHONE_REGEX; /** * Validates and sanitizes USSD input * @param input Raw user input * @param maxLength Maximum allowed length (default 160 for USSD) * @returns Sanitized input * @throws Error if input is invalid */ static validateUserInput(input: string, maxLength?: number): string; /** * Validates session IDs * @param sessionId Session identifier * @returns Validated session ID * @throws Error if invalid */ static validateSessionId(sessionId: string): string; /** * Validates and sanitizes phone numbers * @param msisdn Phone number * @param allowInternational Whether to allow international format * @returns Sanitized phone number * @throws Error if invalid */ static validatePhoneNumber(msisdn: string, allowInternational?: boolean): string; /** * Validates menu option selection * @param option User's menu selection * @param validOptions Array of valid options * @returns Validated option * @throws Error if invalid */ static validateMenuOption(option: string, validOptions: string[]): string; /** * Validates numeric input (e.g., amounts, PINs) * @param input Numeric input * @param minLength Minimum length * @param maxLength Maximum length * @returns Validated numeric string * @throws Error if invalid */ static validateNumericInput(input: string, minLength?: number, maxLength?: number, skipWeakCheck?: boolean): string; /** * Validates PIN input * @param pin PIN input * @param length Expected PIN length * @returns Validated PIN * @throws Error if invalid */ static validatePIN(pin: string, length?: number): string; /** * Validates amount input (money) * @param amount Amount input * @param minAmount Minimum allowed amount * @param maxAmount Maximum allowed amount * @returns Validated amount as number * @throws Error if invalid */ static validateAmount(amount: string, minAmount?: number, maxAmount?: number): number; /** * Checks for common injection patterns */ private static containsInjectionPattern; /** * Checks for weak numeric patterns */ private static isWeakNumericPattern; /** * Checks for weak PINs */ private static isWeakPIN; /** * Sanitizes text for safe display * @param text Text to sanitize * @returns Sanitized text */ static sanitizeForDisplay(text: string): string; } //# sourceMappingURL=input-validator.d.ts.map