UNPKG

@temboplus/frontend-core

Version:

A JavaScript/TypeScript package providing common utilities and logic shared across front-end TemboPlus projects.

45 lines (44 loc) 2.2 kB
import { ISO2CountryCode } from "@models/country/country.types.js"; import { MNOInfo } from "@models/phone-number/mno/mno.types.js"; import { PhoneNumber } from "@models/phone-number/phone-number.js"; import { type ParsedPhoneNumber, PhoneNumberService } from "@models/phone-number/phone-number.service.js"; import { type PhoneNumberContract, type PhoneNumberParseOptions, PhoneNumberType } from "@models/phone-number/phone-number.types.js"; /** * Represents a validated Tanzanian (TZ) **mobile** phone number. * Extends the generic PhoneNumber class and provides TZ-specific behavior. */ export declare class TZMobileNumber extends PhoneNumber implements PhoneNumberContract { readonly countryCode: ISO2CountryCode; /** * Protected constructor. Use static `from` method for instantiation. * Calls the base class constructor. */ protected constructor(parsedInfo: ParsedPhoneNumber, service: PhoneNumberService); /** * Validates the structure for a Tanzanian **mobile** phone number. * Checks base validity AND ensures the prefix belongs to a known TZ MNO. * @returns {boolean} True if the number is a valid TZ mobile number. */ validate(): boolean; /** * Gets associated Tanzanian mobile operator information based on the number's prefix. * Overrides the base implementation. * @returns {MNOInfo | undefined} Operator details or undefined. */ getOperatorInfo(): MNOInfo | undefined; /** * Gets the specific type for this class, overriding the base method. * @returns {PhoneNumberType} Always returns MOBILE. */ getNumberType(): PhoneNumberType; /** * Attempts to create a `TZMobileNumber` instance from a given string input. * Performs TZ-specific parsing and validation FIRST, then uses the core * service for final validation and object creation. * * @param input - The input phone number string. * @param options - Parsing options (optional). * @returns {TZMobileNumber | undefined} An instance if valid, otherwise undefined. */ static from(input: string | null | undefined, options?: PhoneNumberParseOptions): TZMobileNumber | undefined; }