From d846a3f500ba1db53b3573b90b1d4fa10fae82b1 Mon Sep 17 00:00:00 2001 From: moser-jose Date: Sun, 26 Jan 2025 01:56:44 +0100 Subject: [PATCH 1/3] angola Phone Number and PASSPORT NUMBER validations --- src/lib/isMobilePhone.js | 2 +- src/lib/isPassportNumber.js | 1 + test/validators.test.js | 16 +++++++++++++++- 3 files changed, 17 insertions(+), 2 deletions(-) diff --git a/src/lib/isMobilePhone.js b/src/lib/isMobilePhone.js index 393ee6fbd..4ab395337 100644 --- a/src/lib/isMobilePhone.js +++ b/src/lib/isMobilePhone.js @@ -136,7 +136,7 @@ const phones = { 'pl-PL': /^(\+?48)? ?([5-8]\d|45) ?\d{3} ?\d{2} ?\d{2}$/, 'pt-BR': /^((\+?55\ ?[1-9]{2}\ ?)|(\+?55\ ?\([1-9]{2}\)\ ?)|(0[1-9]{2}\ ?)|(\([1-9]{2}\)\ ?)|([1-9]{2}\ ?))((\d{4}\-?\d{4})|(9[1-9]{1}\d{3}\-?\d{4}))$/, 'pt-PT': /^(\+?351)?9[1236]\d{7}$/, - 'pt-AO': /^(\+244)\d{9}$/, + 'pt-AO': /^\+244222\d{6}$|^\+244\d{9}$/, 'ro-MD': /^(\+?373|0)((6(0|1|2|6|7|8|9))|(7(6|7|8|9)))\d{6}$/, 'ro-RO': /^(\+?40|0)\s?7\d{2}(\/|\s|\.|-)?\d{3}(\s|\.|-)?\d{3}$/, 'ru-RU': /^(\+?7|8)?9\d{9}$/, diff --git a/src/lib/isPassportNumber.js b/src/lib/isPassportNumber.js index 92282ac78..fb6d9b808 100644 --- a/src/lib/isPassportNumber.js +++ b/src/lib/isPassportNumber.js @@ -9,6 +9,7 @@ import assertString from './util/assertString'; const passportRegexByCountryCode = { AM: /^[A-Z]{2}\d{7}$/, // ARMENIA AR: /^[A-Z]{3}\d{6}$/, // ARGENTINA + AO: /^N\d{7}$/, // ANGOLA AT: /^[A-Z]\d{7}$/, // AUSTRIA AU: /^[A-Z]\d{7}$/, // AUSTRALIA AZ: /^[A-Z]{1}\d{8}$/, // AZERBAIJAN diff --git a/test/validators.test.js b/test/validators.test.js index d0908ad12..3979be7c7 100644 --- a/test/validators.test.js +++ b/test/validators.test.js @@ -2984,6 +2984,18 @@ describe('Validators', () => { ], }); + test({ + validator: 'isPassportNumber', + args: ['AO'], + valid: [ + 'N4560459', + ], + invalid: [ + 'N090993420', + 'N43044347', + ], + }); + test({ validator: 'isPassportNumber', args: ['AR'], @@ -10370,7 +10382,9 @@ describe('Validators', () => { locale: 'pt-AO', valid: [ '+244911123432', - '+244123091232', + '+244923819817', + '+244222893533', + '+244625893533', ], invalid: [ '+2449111234321', From d90248686d932104ee14a81dce8a4b3ed5069400 Mon Sep 17 00:00:00 2001 From: moser-jose Date: Sun, 26 Jan 2025 02:07:16 +0100 Subject: [PATCH 2/3] angola Mobile Phone --- src/lib/isMobilePhone.js | 2 +- test/validators.test.js | 2 -- 2 files changed, 1 insertion(+), 3 deletions(-) diff --git a/src/lib/isMobilePhone.js b/src/lib/isMobilePhone.js index 4ab395337..fa6bdccfa 100644 --- a/src/lib/isMobilePhone.js +++ b/src/lib/isMobilePhone.js @@ -136,7 +136,7 @@ const phones = { 'pl-PL': /^(\+?48)? ?([5-8]\d|45) ?\d{3} ?\d{2} ?\d{2}$/, 'pt-BR': /^((\+?55\ ?[1-9]{2}\ ?)|(\+?55\ ?\([1-9]{2}\)\ ?)|(0[1-9]{2}\ ?)|(\([1-9]{2}\)\ ?)|([1-9]{2}\ ?))((\d{4}\-?\d{4})|(9[1-9]{1}\d{3}\-?\d{4}))$/, 'pt-PT': /^(\+?351)?9[1236]\d{7}$/, - 'pt-AO': /^\+244222\d{6}$|^\+244\d{9}$/, + 'pt-AO': /^(\+?244|00244|)9\d{8}$/, 'ro-MD': /^(\+?373|0)((6(0|1|2|6|7|8|9))|(7(6|7|8|9)))\d{6}$/, 'ro-RO': /^(\+?40|0)\s?7\d{2}(\/|\s|\.|-)?\d{3}(\s|\.|-)?\d{3}$/, 'ru-RU': /^(\+?7|8)?9\d{9}$/, diff --git a/test/validators.test.js b/test/validators.test.js index 3979be7c7..be55cda2a 100644 --- a/test/validators.test.js +++ b/test/validators.test.js @@ -10383,8 +10383,6 @@ describe('Validators', () => { valid: [ '+244911123432', '+244923819817', - '+244222893533', - '+244625893533', ], invalid: [ '+2449111234321', From f7a037b897d7994541c984ddfe3834a36644d21c Mon Sep 17 00:00:00 2001 From: moser-jose Date: Sun, 26 Jan 2025 02:31:25 +0100 Subject: [PATCH 3/3] update readme angola passport number --- README.md | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/README.md b/README.md index 791fb53c5..94f541b9b 100644 --- a/README.md +++ b/README.md @@ -154,7 +154,7 @@ Validator | Description **isMultibyte(str)** | check if the string contains one or more multibyte chars. **isNumeric(str [, options])** | check if the string contains only numbers.

`options` is an object which defaults to `{ no_symbols: false }` it also has `locale` as an option. If `no_symbols` is true, the validator will reject numeric strings that feature a symbol (e.g. `+`, `-`, or `.`).

`locale` determines the decimal separator and is one of `['ar', 'ar-AE', 'ar-BH', 'ar-DZ', 'ar-EG', 'ar-IQ', 'ar-JO', 'ar-KW', 'ar-LB', 'ar-LY', 'ar-MA', 'ar-QA', 'ar-QM', 'ar-SA', 'ar-SD', 'ar-SY', 'ar-TN', 'ar-YE', 'bg-BG', 'cs-CZ', 'da-DK', 'de-DE', 'en-AU', 'en-GB', 'en-HK', 'en-IN', 'en-NZ', 'en-US', 'en-ZA', 'en-ZM', 'eo', 'es-ES', 'fr-FR', 'fr-CA', 'hu-HU', 'it-IT', 'nb-NO', 'nl-NL', 'nn-NO', 'pl-PL', 'pt-BR', 'pt-PT', 'ru-RU', 'sl-SI', 'sr-RS', 'sr-RS@latin', 'sv-SE', 'tr-TR', 'uk-UA']`. **isOctal(str)** | check if the string is a valid octal number. -**isPassportNumber(str, countryCode)** | check if the string is a valid passport number.

`countryCode` is one of `['AM', 'AR', 'AT', 'AU', 'AZ', 'BE', 'BG', 'BY', 'BR', 'CA', 'CH', 'CN', 'CY', 'CZ', 'DE', 'DK', 'DZ', 'EE', 'ES', 'FI', 'FR', 'GB', 'GR', 'HR', 'HU', 'IE', 'IN', 'IR', 'ID', 'IS', 'IT', 'JM', 'JP', 'KR', 'KZ', 'LI', 'LT', 'LU', 'LV', 'LY', 'MT', 'MX', 'MY', 'MZ', 'NL', 'NZ', 'PH', 'PK', 'PL', 'PT', 'RO', 'RU', 'SE', 'SL', 'SK', 'TH', 'TR', 'UA', 'US', 'ZA']`. Locale list is `validator.passportNumberLocales`. +**isPassportNumber(str, countryCode)** | check if the string is a valid passport number.

`countryCode` is one of `['AM', 'AR', 'AO', 'AT', 'AU', 'AZ', 'BE', 'BG', 'BY', 'BR', 'CA', 'CH', 'CN', 'CY', 'CZ', 'DE', 'DK', 'DZ', 'EE', 'ES', 'FI', 'FR', 'GB', 'GR', 'HR', 'HU', 'IE', 'IN', 'IR', 'ID', 'IS', 'IT', 'JM', 'JP', 'KR', 'KZ', 'LI', 'LT', 'LU', 'LV', 'LY', 'MT', 'MX', 'MY', 'MZ', 'NL', 'NZ', 'PH', 'PK', 'PL', 'PT', 'RO', 'RU', 'SE', 'SL', 'SK', 'TH', 'TR', 'UA', 'US', 'ZA']`. Locale list is `validator.passportNumberLocales`. **isPort(str)** | check if the string is a valid port number. **isPostalCode(str, locale)** | check if the string is a postal code.

`locale` is one of `['AD', 'AT', 'AU', 'AZ', 'BA', 'BE', 'BG', 'BR', 'BY', 'CA', 'CH', 'CN', 'CO', 'CZ', 'DE', 'DK', 'DO', 'DZ', 'EE', 'ES', 'FI', 'FR', 'GB', 'GR', 'HR', 'HT', 'HU', 'ID', 'IE', 'IL', 'IN', 'IR', 'IS', 'IT', 'JP', 'KE', 'KR', 'LI', 'LK', 'LT', 'LU', 'LV', 'MG', 'MT', 'MX', 'MY', 'NL', 'NO', 'NP', 'NZ', 'PL', 'PR', 'PT', 'RO', 'RU', 'SA', 'SE', 'SG', 'SI', 'SK', 'TH', 'TN', 'TW', 'UA', 'US', 'ZA', 'ZM']` OR `'any'`. If 'any' is used, function will check if any of the locales match. Locale list is `validator.isPostalCodeLocales`. **isRFC3339(str)** | check if the string is a valid [RFC 3339][RFC 3339] date.