From f81d85702b06ba1e0a624d4d345cacdde46ed3e0 Mon Sep 17 00:00:00 2001 From: "Ahmed H. Ismail" Date: Sat, 22 Jun 2024 18:58:44 +0100 Subject: [PATCH 1/2] feat(isRgbColor): add `allowSpaces` option to allow/disallow spaces between color values (#2029) Co-authored-by: Brage Sekse Aarset --- README.md | 2 +- src/lib/isRgbColor.js | 25 ++++- test/validators.test.js | 197 ++++++++++++++++++++++++++++++++++++++++ 3 files changed, 222 insertions(+), 2 deletions(-) diff --git a/README.md b/README.md index 46ac0d5c4..9514069d1 100644 --- a/README.md +++ b/README.md @@ -158,7 +158,7 @@ Validator | Description **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. -**isRgbColor(str [, includePercentValues])** | check if the string is a rgb or rgba color.

`includePercentValues` defaults to `true`. If you don't want to allow to set `rgb` or `rgba` values with percents, like `rgb(5%,5%,5%)`, or `rgba(90%,90%,90%,.3)`, then set it to false. +**isRgbColor(str [,options])** | check if the string is a rgb or rgba color.

`options` is an object with the following properties

`includePercentValues` defaults to `true`. If you don't want to allow to set `rgb` or `rgba` values with percents, like `rgb(5%,5%,5%)`, or `rgba(90%,90%,90%,.3)`, then set it to false.

`allowSpaces` defaults to `true`, which prohibits whitespace. If set to false, whitespace between color values is allowed, such as `rgb(255, 255, 255)` or even `rgba(255, 128, 0, 0.7)`. **isSemVer(str)** | check if the string is a Semantic Versioning Specification (SemVer). **isSurrogatePair(str)** | check if the string contains any surrogate pairs chars. **isUppercase(str)** | check if the string is uppercase. diff --git a/src/lib/isRgbColor.js b/src/lib/isRgbColor.js index 9458522ab..5267d563d 100644 --- a/src/lib/isRgbColor.js +++ b/src/lib/isRgbColor.js @@ -1,12 +1,35 @@ +/* eslint-disable prefer-rest-params */ import assertString from './util/assertString'; const rgbColor = /^rgb\((([0-9]|[1-9][0-9]|1[0-9][0-9]|2[0-4][0-9]|25[0-5]),){2}([0-9]|[1-9][0-9]|1[0-9][0-9]|2[0-4][0-9]|25[0-5])\)$/; const rgbaColor = /^rgba\((([0-9]|[1-9][0-9]|1[0-9][0-9]|2[0-4][0-9]|25[0-5]),){3}(0?\.\d|1(\.0)?|0(\.0)?)\)$/; const rgbColorPercent = /^rgb\((([0-9]%|[1-9][0-9]%|100%),){2}([0-9]%|[1-9][0-9]%|100%)\)$/; const rgbaColorPercent = /^rgba\((([0-9]%|[1-9][0-9]%|100%),){3}(0?\.\d|1(\.0)?|0(\.0)?)\)$/; +const startsWithRgb = /^rgba?/; -export default function isRgbColor(str, includePercentValues = true) { +export default function isRgbColor(str, options) { assertString(str); + // default options to true for percent and false for spaces + let allowSpaces = false; + let includePercentValues = true; + if (typeof options !== 'object') { + if (arguments.length >= 2) { + includePercentValues = arguments[1]; + } + } else { + allowSpaces = options.allowSpaces !== undefined ? options.allowSpaces : allowSpaces; + includePercentValues = options.includePercentValues !== undefined ? + options.includePercentValues : includePercentValues; + } + + if (allowSpaces) { + // make sure it starts with continous rgba? without spaces before stripping + if (!startsWithRgb.test(str)) { + return false; + } + // strip all whitespace + str = str.replace(/\s/g, ''); + } if (!includePercentValues) { return rgbColor.test(str) || rgbaColor.test(str); diff --git a/test/validators.test.js b/test/validators.test.js index 152b56f6b..b0382bb82 100644 --- a/test/validators.test.js +++ b/test/validators.test.js @@ -4736,9 +4736,53 @@ describe('Validators', () => { 'rgba(3%,3%,101%,0.3)', 'rgb(101%,101%,101%) additional invalid string part', 'rgba(3%,3%,101%,0.3) additional invalid string part', + 'r g b( 0, 251, 222 )', + 'r g ba( 0, 251, 222 )', + 'rg ba(0, 251, 22, 0.5)', + 'rgb( 255,255 ,255)', + 'rgba(255, 255, 255, 0.5)', + 'rgba(255, 255, 255, 0.5)', + 'rgb(5%, 5%, 5%)', ], }); + // test empty options object + test({ + validator: 'isRgbColor', + args: [{}], + valid: [ + 'rgb(0,0,0)', + 'rgb(255,255,255)', + 'rgba(0,0,0,0)', + 'rgba(255,255,255,1)', + 'rgba(255,255,255,.1)', + 'rgba(255,255,255,0.1)', + 'rgb(5%,5%,5%)', + 'rgba(5%,5%,5%,.3)', + ], + invalid: [ + 'rgb(0,0,0,)', + 'rgb(0,0,)', + 'rgb(0,0,256)', + 'rgb()', + 'rgba(0,0,0)', + 'rgba(255,255,255,2)', + 'rgba(255,255,255,.12)', + 'rgba(255,255,256,0.1)', + 'rgb(4,4,5%)', + 'rgba(5%,5%,5%)', + 'rgba(3,3,3%,.3)', + 'rgb(101%,101%,101%)', + 'rgba(3%,3%,101%,0.3)', + 'r g b( 0, 251, 222 )', + 'r g ba( 0, 251, 222 )', + 'rg ba(0, 251, 22, 0.5)', + 'rgb( 255,255 ,255)', + 'rgba(255, 255, 255, 0.5)', + 'rgba(255, 255, 255, 0.5)', + 'rgb(5%, 5%, 5%)', + ], + }); // test where includePercentValues is given as false test({ validator: 'isRgbColor', @@ -4750,6 +4794,159 @@ describe('Validators', () => { invalid: [ 'rgb(4,4,5%)', 'rgba(5%,5%,5%)', + 'r g b( 0, 251, 222 )', + 'r g ba( 0, 251, 222 )', + ], + }); + + // test where includePercentValues is given as false as part of options object + test({ + validator: 'isRgbColor', + args: [{ includePercentValues: false }], + valid: [ + 'rgb(5,5,5)', + 'rgba(5,5,5,.3)', + ], + invalid: [ + 'rgb(4,4,5%)', + 'rgba(5%,5%,5%)', + 'r g b( 0, 251, 222 )', + 'rgba(255, 255, 255 ,0.2)', + 'r g ba( 0, 251, 222 )', + ], + }); + + // test where include percent is true explciitly + test({ + validator: 'isRgbColor', + args: [true], + valid: [ + 'rgb(5,5,5)', + 'rgba(5,5,5,.3)', + 'rgb(0,0,0)', + 'rgb(255,255,255)', + 'rgba(0,0,0,0)', + 'rgba(255,255,255,1)', + 'rgba(255,255,255,.1)', + 'rgba(255,255,255,0.1)', + 'rgb(5%,5%,5%)', + 'rgba(5%,5%,5%,.3)', + 'rgb(5%,5%,5%)', + 'rgba(255,255,255,0.5)', + ], + invalid: [ + 'rgba(255, 255, 255, 0.5)', + 'rgb(5%, 5%, 5%)', + 'rgb(4,4,5%)', + 'rgba(5%,5%,5%)', + 'r g b( 0, 251, 222 )', + 'r g ba( 0, 251, 222 )', + 'rgb(0,0,0,)', + 'rgb(0,0,)', + 'rgb(0,0,256)', + 'rgb()', + 'rgba(0,0,0)', + 'rgba(255,255,255,2)', + 'rgba(255,255,255,.12)', + 'rgba(255,255,256,0.1)', + 'rgb(4,4,5%)', + 'rgba(5%,5%,5%)', + 'rgba(3,3,3%,.3)', + 'rgb(101%,101%,101%)', + 'rgba(3%,3%,101%,0.3)', + ], + }); + + // test where percent value is false and allowSpaces is true as part of options object + test({ + validator: 'isRgbColor', + args: [{ includePercentValues: false, allowSpaces: true }], + valid: [ + 'rgb(5,5,5)', + 'rgba(5,5,5,.3)', + 'rgba(255,255,255,0.2)', + 'rgba(255, 255, 255 ,0.2)', + ], + invalid: [ + 'rgb(4,4,5%)', + 'rgba(5%,5%,5%)', + 'rgba(5% ,5%, 5%)', + 'r g b( 0, 251, 222 )', + 'r g ba( 0, 251, 222 )', + 'rgb(0,0,)', + 'rgb()', + 'rgb(4,4,5%)', + 'rgb(5%,5%,5%)', + 'rgba(3,3,3%,.3)', + 'rgb(101%, 101%, 101%)', + 'rgba(3%,3%,101%,0.3)', + ], + + }); + + // test where both are true as part of options object + test({ + validator: 'isRgbColor', + args: [{ includePercentValues: true, allowSpaces: true }], + valid: [ + 'rgb( 5, 5, 5)', + 'rgba(5, 5, 5, .3)', + 'rgb(0, 0, 0)', + 'rgb(255, 255, 255)', + 'rgba(0, 0, 0, 0)', + 'rgba(255, 255, 255, 1)', + 'rgba(255, 255, 255, .1)', + 'rgba(255, 255, 255, 0.1)', + 'rgb(5% ,5% ,5%)', + 'rgba(5%,5%,5%, .3)', + ], + invalid: [ + 'r g b( 0, 251, 222 )', + 'rgb(4,4,5%)', + 'rgb(101%,101%,101%)', + + ], + }); + + // test where allowSpaces is false as part of options object + test({ + validator: 'isRgbColor', + args: [{ includePercentValues: true, allowSpaces: false }], + valid: [ + 'rgb(5,5,5)', + 'rgba(5,5,5,.3)', + 'rgb(0,0,0)', + 'rgb(255,255,255)', + 'rgba(0,0,0,0)', + 'rgba(255,255,255,1)', + 'rgba(255,255,255,.1)', + 'rgba(255,255,255,0.1)', + 'rgb(5%,5%,5%)', + 'rgba(5%,5%,5%,.3)', + + ], + invalid: [ + 'rgb( 255,255 ,255)', + 'rgba(255, 255, 255, 0.5)', + 'rgb(5%, 5%, 5%)', + 'rgba(255, 255, 255, 0.5)', + 'rgb(4,4,5%)', + 'rgba(5%,5%,5%)', + 'r g b( 0, 251, 222 )', + 'r g ba( 0, 251, 222 )', + 'rgb(0,0,0,)', + 'rgb(0,0,)', + 'rgb(0,0,256)', + 'rgb()', + 'rgba(0,0,0)', + 'rgba(255,255,255,2)', + 'rgba(255,255,255,.12)', + 'rgba(255,255,256,0.1)', + 'rgb(4,4,5%)', + 'rgba(5%,5%,5%)', + 'rgba(3,3,3%,.3)', + 'rgb(101%,101%,101%)', + 'rgba(3%,3%,101%,0.3)', ], }); }); From 89e856c778b7aafb532c570d99b61d0d327c6ad4 Mon Sep 17 00:00:00 2001 From: Robert Kieffer Date: Sat, 22 Jun 2024 11:53:17 -0700 Subject: [PATCH 2/2] fix(isUUID): fully support rfc9562 (#2421) --- README.md | 2 +- src/lib/isUUID.js | 23 +++++++++++++++------ test/validators.test.js | 45 +++++++++++++++++++++++++++++++++++------ 3 files changed, 57 insertions(+), 13 deletions(-) diff --git a/README.md b/README.md index 9514069d1..873c01ef0 100644 --- a/README.md +++ b/README.md @@ -167,7 +167,7 @@ Validator | Description **isTime(str [, options])** | check if the string is a valid time e.g. [`23:01:59`, new Date().toLocaleTimeString()].

`options` is an object which can contain the keys `hourFormat` or `mode`.

`hourFormat` is a key and defaults to `'hour24'`.

`mode` is a key and defaults to `'default'`.

`hourFormat` can contain the values `'hour12'` or `'hour24'`, `'hour24'` will validate hours in 24 format and `'hour12'` will validate hours in 12 format.

`mode` can contain the values `'default'` or `'withSeconds'`, `'default'` will validate `HH:MM` format, `'withSeconds'` will validate the `HH:MM:SS` format. **isTaxID(str, locale)** | check if the string is a valid Tax Identification Number. Default locale is `en-US`.

More info about exact TIN support can be found in `src/lib/isTaxID.js`.

Supported locales: `[ 'bg-BG', 'cs-CZ', 'de-AT', 'de-DE', 'dk-DK', 'el-CY', 'el-GR', 'en-CA', 'en-GB', 'en-IE', 'en-US', 'es-AR', 'es-ES', 'et-EE', 'fi-FI', 'fr-BE', 'fr-CA', 'fr-FR', 'fr-LU', 'hr-HR', 'hu-HU', 'it-IT', 'lb-LU', 'lt-LT', 'lv-LV', 'mt-MT', 'nl-BE', 'nl-NL', 'pl-PL', 'pt-BR', 'pt-PT', 'ro-RO', 'sk-SK', 'sl-SI', 'sv-SE', 'uk-UA']`. **isURL(str [, options])** | check if the string is a URL.

`options` is an object which defaults to `{ protocols: ['http','https','ftp'], require_tld: true, require_protocol: false, require_host: true, require_port: false, require_valid_protocol: true, allow_underscores: false, host_whitelist: false, host_blacklist: false, allow_trailing_dot: false, allow_protocol_relative_urls: false, allow_fragments: true, allow_query_components: true, disallow_auth: false, validate_length: true }`.

`require_protocol` - if set to true isURL will return false if protocol is not present in the URL.
`require_valid_protocol` - isURL will check if the URL's protocol is present in the protocols option.
`protocols` - valid protocols can be modified with this option.
`require_host` - if set to false isURL will not check if host is present in the URL.
`require_port` - if set to true isURL will check if port is present in the URL.
`allow_protocol_relative_urls` - if set to true protocol relative URLs will be allowed.
`allow_fragments` - if set to false isURL will return false if fragments are present.
`allow_query_components` - if set to false isURL will return false if query components are present.
`validate_length` - if set to false isURL will skip string length validation (2083 characters is IE max URL length). -**isUUID(str [, version])** | check if the string is a UUID (version 1, 2, 3, 4, 5 or 7). +**isUUID(str [, version])** | check if the string is an RFC9562 UUID.
`version` is one of `'1'`-`'8'`, `'nil'`, `'max'`, or `'all'`. **isVariableWidth(str)** | check if the string contains a mixture of full and half-width chars. **isVAT(str, countryCode)** | check if the string is a [valid VAT number][VAT Number] if validation is available for the given country code matching [ISO 3166-1 alpha-2][ISO 3166-1 alpha-2].

`countryCode` is one of `['AL', 'AR', 'AT', 'AU', 'BE', 'BG', 'BO', 'BR', 'BY', 'CA', 'CH', 'CL', 'CO', 'CR', 'CY', 'CZ', 'DE', 'DK', 'DO', 'EC', 'EE', 'EL', 'ES', 'FI', 'FR', 'GB', 'GT', 'HN', 'HR', 'HU', 'ID', 'IE', 'IL', 'IN', 'IS', 'IT', 'KZ', 'LT', 'LU', 'LV', 'MK', 'MT', 'MX', 'NG', 'NI', 'NL', 'NO', 'NZ', 'PA', 'PE', 'PH', 'PL', 'PT', 'PY', 'RO', 'RS', 'RU', 'SA', 'SE', 'SI', 'SK', 'SM', 'SV', 'TR', 'UA', 'UY', 'UZ', 'VE']`. **isWhitelisted(str, chars)** | check if the string consists only of characters that appear in the whitelist `chars`. diff --git a/src/lib/isUUID.js b/src/lib/isUUID.js index 512141df6..786af002e 100644 --- a/src/lib/isUUID.js +++ b/src/lib/isUUID.js @@ -1,17 +1,28 @@ import assertString from './util/assertString'; const uuid = { - 1: /^[0-9A-F]{8}-[0-9A-F]{4}-1[0-9A-F]{3}-[0-9A-F]{4}-[0-9A-F]{12}$/i, - 2: /^[0-9A-F]{8}-[0-9A-F]{4}-2[0-9A-F]{3}-[0-9A-F]{4}-[0-9A-F]{12}$/i, - 3: /^[0-9A-F]{8}-[0-9A-F]{4}-3[0-9A-F]{3}-[0-9A-F]{4}-[0-9A-F]{12}$/i, + 1: /^[0-9A-F]{8}-[0-9A-F]{4}-1[0-9A-F]{3}-[89AB][0-9A-F]{3}-[0-9A-F]{12}$/i, + 2: /^[0-9A-F]{8}-[0-9A-F]{4}-2[0-9A-F]{3}-[89AB][0-9A-F]{3}-[0-9A-F]{12}$/i, + 3: /^[0-9A-F]{8}-[0-9A-F]{4}-3[0-9A-F]{3}-[89AB][0-9A-F]{3}-[0-9A-F]{12}$/i, 4: /^[0-9A-F]{8}-[0-9A-F]{4}-4[0-9A-F]{3}-[89AB][0-9A-F]{3}-[0-9A-F]{12}$/i, 5: /^[0-9A-F]{8}-[0-9A-F]{4}-5[0-9A-F]{3}-[89AB][0-9A-F]{3}-[0-9A-F]{12}$/i, + 6: /^[0-9A-F]{8}-[0-9A-F]{4}-6[0-9A-F]{3}-[89AB][0-9A-F]{3}-[0-9A-F]{12}$/i, 7: /^[0-9A-F]{8}-[0-9A-F]{4}-7[0-9A-F]{3}-[89AB][0-9A-F]{3}-[0-9A-F]{12}$/i, - all: /^[0-9A-F]{8}-[0-9A-F]{4}-[0-9A-F]{4}-[0-9A-F]{4}-[0-9A-F]{12}$/i, + 8: /^[0-9A-F]{8}-[0-9A-F]{4}-8[0-9A-F]{3}-[89AB][0-9A-F]{3}-[0-9A-F]{12}$/i, + + nil: /^00000000-0000-0000-0000-000000000000$/i, + max: /^ffffffff-ffff-ffff-ffff-ffffffffffff$/i, + + // From https://github.com/uuidjs/uuid/blob/main/src/regex.js + all: /^(?:[0-9a-f]{8}-[0-9a-f]{4}-[1-8][0-9a-f]{3}-[89ab][0-9a-f]{3}-[0-9a-f]{12}|00000000-0000-0000-0000-000000000000|ffffffff-ffff-ffff-ffff-ffffffffffff)$/i, }; export default function isUUID(str, version) { assertString(str); - const pattern = uuid[![undefined, null].includes(version) ? version : 'all']; - return !!pattern && pattern.test(str); + + if (version === undefined || version === null) { + version = 'all'; + } + + return version in uuid ? uuid[version].test(str) : false; } diff --git a/test/validators.test.js b/test/validators.test.js index b0382bb82..1c1eb352a 100644 --- a/test/validators.test.js +++ b/test/validators.test.js @@ -5424,14 +5424,17 @@ describe('Validators', () => { test({ validator: 'isUUID', valid: [ - 'A987FBC9-4BED-3078-CF07-9141BA07C9F3', + '9deb20fe-a6e0-355c-81ea-288b009e4f6d', 'A987FBC9-4BED-4078-8F07-9141BA07C9F3', 'A987FBC9-4BED-5078-AF07-9141BA07C9F3', + 'A987FBC9-4BED-6078-AF07-9141BA07C9F3', '018C544A-D384-7000-BB74-3B1738ABE43C', + 'A987FBC9-4BED-8078-AF07-9141BA07C9F3', ], invalid: [ '', 'xxxA987FBC9-4BED-3078-CF07-9141BA07C9F3', + 'A987FBC9-4BED-3078-CF07-9141BA07C9F3', 'A987FBC9-4BED-3078-CF07-9141BA07C9F3xxx', 'A987FBC94BED3078CF079141BA07C9F3', '934859', @@ -5443,12 +5446,13 @@ describe('Validators', () => { validator: 'isUUID', args: [undefined], valid: [ - 'A117FBC9-4BED-3078-CF07-9141BA07C9F3', + '9deb20fe-a6e0-355c-81ea-288b009e4f6d', 'A117FBC9-4BED-5078-AF07-9141BA07C9F3', '018C544A-D384-7000-BB74-3B1738ABE43C', ], invalid: [ '', + 'A117FBC9-4BED-3078-CF07-9141BA07C9F3', 'xxxA987FBC9-4BED-3078-CF07-9141BA07C9F3', 'A987FBC94BED3078CF079141BA07C9F3', 'A11AAAAA-1111-1111-AAAG-111111111111', @@ -5458,12 +5462,13 @@ describe('Validators', () => { validator: 'isUUID', args: [null], valid: [ - 'A127FBC9-4BED-3078-CF07-9141BA07C9F3', + 'A127FBC9-4BED-3078-AF07-9141BA07C9F3', '018C544A-D384-7000-BB74-3B1738ABE43C', ], invalid: [ '', 'xxxA987FBC9-4BED-3078-CF07-9141BA07C9F3', + 'A127FBC9-4BED-3078-CF07-9141BA07C9F3', 'A127FBC9-4BED-3078-CF07-9141BA07C9F3xxx', '912859', 'A12AAAAA-1111-1111-AAAG-111111111111', @@ -5488,13 +5493,14 @@ describe('Validators', () => { validator: 'isUUID', args: [2], valid: [ - 'A987FBC9-4BED-2078-CF07-9141BA07C9F3', + 'A987FBC9-4BED-2078-AF07-9141BA07C9F3', ], invalid: [ '', 'xxxA987FBC9-4BED-3078-CF07-9141BA07C9F3', '11111', 'AAAAAAAA-1111-1111-AAAG-111111111111', + 'A987FBC9-4BED-2078-CF07-9141BA07C9F3', 'A987FBC9-4BED-4078-8F07-9141BA07C9F3', 'A987FBC9-4BED-5078-AF07-9141BA07C9F3', '018C544A-D384-7000-BB74-3B1738ABE43C', @@ -5504,10 +5510,11 @@ describe('Validators', () => { validator: 'isUUID', args: [3], valid: [ - 'A987FBC9-4BED-3078-CF07-9141BA07C9F3', + '9deb20fe-a6e0-355c-81ea-288b009e4f6d', ], invalid: [ '', + 'A987FBC9-4BED-3078-CF07-9141BA07C9F3', 'xxxA987FBC9-4BED-3078-CF07-9141BA07C9F3', '934859', 'AAAAAAAA-1111-1111-AAAG-111111111111', @@ -5557,7 +5564,9 @@ describe('Validators', () => { test({ validator: 'isUUID', args: [6], - valid: [], + valid: [ + '1ef29908-cde1-69d0-be16-bfc8518a95f0', + ], invalid: [ '987FBC97-4BED-1078-AF07-9141BA07C9F3', '987FBC97-4BED-2078-AF07-9141BA07C9F3', @@ -5565,6 +5574,7 @@ describe('Validators', () => { '987FBC97-4BED-4078-AF07-9141BA07C9F3', '987FBC97-4BED-5078-AF07-9141BA07C9F3', '018C544A-D384-7000-BB74-3B1738ABE43C', + '987FBC97-4BED-8078-AF07-9141BA07C9F3', ], }); test({ @@ -5580,6 +5590,29 @@ describe('Validators', () => { 'AAAAAAAA-1111-1111-AAAG-111111111111', 'A987FBC9-4BED-5078-AF07-9141BA07C9F3', 'A987FBC9-4BED-3078-CF07-9141BA07C9F3', + 'A987FBC9-4BED-6078-AF07-9141BA07C9F3', + 'A987FBC9-4BED-8078-AF07-9141BA07C9F3', + '713ae7e3-cb32-45f9-adcb-7c4fa86b90c1', + '625e63f3-58f5-40b7-83a1-a72ad31acffb', + '57b73598-8764-4ad0-a76a-679bb6640eb1', + '9c858901-8a57-4791-81fe-4c455b099bc9', + ], + }); + test({ + validator: 'isUUID', + args: [8], + valid: [ + '018C544A-D384-8000-BB74-3B1738ABE43C', + ], + invalid: [ + '', + 'xxxA987FBC9-4BED-3078-CF07-9141BA07C9F3', + '934859', + 'AAAAAAAA-1111-1111-AAAG-111111111111', + 'A987FBC9-4BED-5078-AF07-9141BA07C9F3', + 'A987FBC9-4BED-3078-CF07-9141BA07C9F3', + 'A987FBC9-4BED-6078-AF07-9141BA07C9F3', + 'A987FBC9-4BED-7078-AF07-9141BA07C9F3', '713ae7e3-cb32-45f9-adcb-7c4fa86b90c1', '625e63f3-58f5-40b7-83a1-a72ad31acffb', '57b73598-8764-4ad0-a76a-679bb6640eb1',