UNPKG

@vn-utils/phone-validate

Version:

A library to validate Vietnamese phone number

22 lines (21 loc) 1.09 kB
import { PhoneInfo, ValidateOptions } from './types'; /** * Get information about a phone number * * @param {string} phoneNumber A phone number to validate * @param {ValidateOptions} options Optional options * @param {('0' | '84' | '+84')[]} [options.startWith] - The allowed prefixes for the phone number. Defaults to ['0']. * @returns {PhoneInfo} Information about the phone number * @throws {Error} phoneNumber is invalid */ export declare function getVNPhoneInfo(phoneNumber: string, options?: ValidateOptions): PhoneInfo; /** * Checks if a given phone number is a valid Vietnamese phone number. * * @param {string} phoneNumber - The phone number to validate. * @param {ValidateOptions} [options] - Optional options for validation. * @param {('0' | '84' | '+84')[]} [options.startWith] - The allowed prefixes for the phone number. Defaults to ['0']. * @return {boolean} Returns true if the phone number is valid, false otherwise. * @throws {Error} phoneNumber is invalid */ export declare function isValidVNPhone(phoneNumber: string, options?: ValidateOptions): boolean;