@vn-utils/phone-validate
Version:
A library to validate Vietnamese phone number
27 lines (26 loc) • 1.09 kB
JavaScript
;
Object.defineProperty(exports, "__esModule", { value: true });
exports.ALL_PROVIDERS_REGEX = exports.VIRTUAL_PROVIDERS_REGEX = exports.PROVIDERS_REGEX = void 0;
exports.PROVIDERS_REGEX = {
Viettel: /(3[2-9]|9[6-8]|86)[0-9]{7}$/,
Vinaphone: /((8[1-5|8]|9[1|4])[0-9]{7})$/,
/**
* 089 is both of Mobifone and Local,
* So we not find 089 as Mobifone
* Move it to `Mobifone & Local` bottom.
*/
Mobifone: /(7[0|6-9]|9[0|3])[0-9]{7}$/,
Vietnamobile: /(5[2|6|8]|92)[0-9]{7}$/,
Gmobile: /(59|99)[0-9]{7}$/,
};
exports.VIRTUAL_PROVIDERS_REGEX = {
// The order of the entries is based on the length of the number to match.
// Entries with shorter numbers should come first.
// For example, an entry with {6} should be placed before an entry with {7}.
Vnsky: /(77[7|8])[0-9]{6}$/,
FPT: /(775)[0-9]{6}$/,
Wintel: /(55)[0-9]{7}$/,
Itel: /(87)[0-9]{7}$/,
Mobifone_Local: /(89)[0-9]{7}$/,
};
exports.ALL_PROVIDERS_REGEX = Object.assign(Object.assign({}, exports.VIRTUAL_PROVIDERS_REGEX), exports.PROVIDERS_REGEX);