From 96ccb7ac99ac5e4e12f9b60d4df1f60492148e63 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Piotr=20B=C5=82a=C5=BCejewicz?= Date: Wed, 23 Mar 2022 22:27:24 +0100 Subject: [PATCH] update(validator): add `isTaxID' validator https://github.com/validatorjs/validator.js/pull/1867 Thanks! Fixes #59419 /cc @wejesuss --- types/validator/es/lib/isTaxId.d.ts | 2 ++ types/validator/index.d.ts | 3 +++ types/validator/lib/isTaxID.d.ts | 9 +++++++++ types/validator/validator-tests.ts | 5 +++++ 4 files changed, 19 insertions(+) create mode 100644 types/validator/es/lib/isTaxId.d.ts create mode 100644 types/validator/lib/isTaxID.d.ts diff --git a/types/validator/es/lib/isTaxId.d.ts b/types/validator/es/lib/isTaxId.d.ts new file mode 100644 index 000000000000000..3d16e3374fd4271 --- /dev/null +++ b/types/validator/es/lib/isTaxId.d.ts @@ -0,0 +1,2 @@ +import validator from '../..'; +export default validator.isTaxID; diff --git a/types/validator/index.d.ts b/types/validator/index.d.ts index 04ed985783aa32a..b5f73415201d382 100644 --- a/types/validator/index.d.ts +++ b/types/validator/index.d.ts @@ -19,6 +19,7 @@ import * as _isFQDN from './lib/isFQDN'; import * as _isIBAN from './lib/isIBAN'; import * as _isISO4217 from './lib/isISO4217'; import * as _isURL from './lib/isURL'; +import * as _isTaxID from './lib/isTaxID'; declare namespace validator { const version: string; @@ -1070,6 +1071,8 @@ declare namespace validator { const isURL: typeof _isURL.default; type IsURLOptions = _isURL.IsURLOptions; + const isTaxID: typeof _isTaxID.default; + /** * Check if the string is uppercase. */ diff --git a/types/validator/lib/isTaxID.d.ts b/types/validator/lib/isTaxID.d.ts new file mode 100644 index 000000000000000..3069e7d942a0208 --- /dev/null +++ b/types/validator/lib/isTaxID.d.ts @@ -0,0 +1,9 @@ +/** + * Validator function + * Return true if the passed string is a valid tax identification number + * for the specified locale. + * Throw an error exception if the locale is not supported. + * @param str + * @param [locale=en-US] + */ +export default function isTaxID(str: string, locale?: string): boolean; diff --git a/types/validator/validator-tests.ts b/types/validator/validator-tests.ts index 6e006e0ba0b1905..72f33a14cf09530 100644 --- a/types/validator/validator-tests.ts +++ b/types/validator/validator-tests.ts @@ -74,6 +74,7 @@ import isStrongPasswordFunc from 'validator/lib/isStrongPassword'; import isSurrogatePairFunc from 'validator/lib/isSurrogatePair'; import isURLFunc from 'validator/lib/isURL'; import isUUIDFunc from 'validator/lib/isUUID'; +import isTaxIDFunc from 'validator/lib/isTaxID'; import isUppercaseFunc from 'validator/lib/isUppercase'; import isVariableWidthFunc from 'validator/lib/isVariableWidth'; import isWhitelistedFunc from 'validator/lib/isWhitelisted'; @@ -301,6 +302,9 @@ import isVatFunc from 'validator/lib/isVAT'; let _isUUID = validator.isUUID; _isUUID = isUUIDFunc; + let _isTaxID = validator.isTaxID; + _isTaxID = isTaxIDFunc; + let _isUppercase = validator.isUppercase; _isUppercase = isUppercaseFunc; @@ -423,6 +427,7 @@ import isStrongPasswordFuncEs from 'validator/es/lib/isStrongPassword'; import isSurrogatePairFuncEs from 'validator/es/lib/isSurrogatePair'; import isURLFuncEs from 'validator/es/lib/isURL'; import isUUIDFuncEs from 'validator/es/lib/isUUID'; +import isTaxIDFuncEs from 'validator/es/lib/isTaxID'; import isUppercaseFuncEs from 'validator/es/lib/isUppercase'; import isVariableWidthFuncEs from 'validator/es/lib/isVariableWidth'; import isWhitelistedFuncEs from 'validator/es/lib/isWhitelisted';