@beenotung/tslib
Version:
utils library in Typescript
32 lines (31 loc) • 1.22 kB
TypeScript
/** ******************************
* Vietnam mobile phone number *
*********************************/
/**
* Checks if the number starts with a valid Vietnam mobile phone prefix
*
* Valid prefixes: 09x, 08x, 07x, 03x, or 05x (where x is any digit)
* Format: 09/08/07/05/03xx xxx xxx (10 digits with leading 0 in local format)
* Reference: https://en.wikipedia.org/wiki/Telephone_numbers_in_Vietnam
*/
export declare function is_vn_mobile_phone_prefix(tel: string): boolean;
/**
* with/without +84 prefix
*/
export declare function is_vn_mobile_phone(tel: number | string): boolean;
/**
* very forgiving
*
* @returns +84xxxxxxxxx if valid (9 digits after country code, NO leading 0 in internal format)
* empty string if not valid
*
* Format notes:
* - Local format: 091 234 5678 (10 digits WITH leading 0) - used in Vietnam
* - Internal format: +84 98 765 4321 (9 digits after +84, NO leading 0) - always 9 digits
* - Display format: +84 98 765 4321 (formatted by format_vn_mobile_phone)
*/
export declare function to_full_vn_mobile_phone(tel: string | number): string;
/**
* @returns +84 AA BBB BBBB if valid
*/
export declare function format_vn_mobile_phone(tel: string | number): string;