From 98e93823ca17beafd33d00e0f0f7cb0fa17037f3 Mon Sep 17 00:00:00 2001 From: Rubin Bhandari Date: Tue, 12 Nov 2019 00:19:03 +0545 Subject: [PATCH] feat: add all option in isuuid validator (#452) --- README.md | 4 ++-- src/decorator/decorators.ts | 2 +- src/validation/Validator.ts | 2 +- 3 files changed, 4 insertions(+), 4 deletions(-) diff --git a/README.md b/README.md index 68178013aa..e3a34a4cdd 100644 --- a/README.md +++ b/README.md @@ -853,7 +853,7 @@ validator.isMongoId(str); // Checks if the string is a valid hex-encoded represe validator.isMultibyte(str); // Checks if the string contains one or more multibyte chars. validator.isSurrogatePair(str); // Checks if the string contains any surrogate pairs chars. validator.isURL(str, options); // Checks if the string is an url. -validator.isUUID(str, version); // Checks if the string is a UUID (version 3, 4 or 5). +validator.isUUID(str, version); // Checks if the string is a UUID (version 3, 4, 5 or all). validator.isUppercase(str); // Checks if the string is uppercase. validator.length(str, min, max); // Checks if the string's length falls in a range. validator.minLength(str, min); // Checks if the string's length is not less than given number. @@ -950,7 +950,7 @@ validator.isInstance(value, target); // Checks value is an instance of the targe | `@IsNumberString()` | Checks if the string is numeric. | | `@IsSurrogatePair()` | Checks if the string contains any surrogate pairs chars. | | `@IsUrl(options?: IsURLOptions)` | Checks if the string is an url. | -| `@IsUUID(version?: "3"\|"4"\|"5")` | Checks if the string is a UUID (version 3, 4 or 5). | +| `@IsUUID(version?: "3"\|"4"\|"5"\|"all")` | Checks if the string is a UUID (version 3, 4, 5 or all ). | | `@IsUppercase()` | Checks if the string is uppercase. | | `@Length(min: number, max?: number)` | Checks if the string's length falls in a range. | | `@MinLength(min: number)` | Checks if the string's length is not less than given number. | diff --git a/src/decorator/decorators.ts b/src/decorator/decorators.ts index 793df42b0a..a1db889758 100644 --- a/src/decorator/decorators.ts +++ b/src/decorator/decorators.ts @@ -1131,7 +1131,7 @@ export function IsUrl(options?: ValidatorJS.IsURLOptions, validationOptions?: Va /** * Checks if the string is a UUID (version 3, 4 or 5). */ -export function IsUUID(version?: "3"|"4"|"5", validationOptions?: ValidationOptions) { +export function IsUUID(version?: "3"|"4"|"5"|"all", validationOptions?: ValidationOptions) { return function (object: Object, propertyName: string) { const args: ValidationMetadataArgs = { type: ValidationTypes.IS_UUID, diff --git a/src/validation/Validator.ts b/src/validation/Validator.ts index b194cff937..a67efdaab8 100644 --- a/src/validation/Validator.ts +++ b/src/validation/Validator.ts @@ -838,7 +838,7 @@ export class Validator { * Checks if the string is a UUID (version 3, 4 or 5). * If given value is not a string, then it returns false. */ - isUUID(value: unknown, version?: "3"|"4"|"5"): boolean { + isUUID(value: unknown, version?: "3"|"4"|"5"|"all"): boolean { return typeof value === "string" && this.validatorJs.isUUID(value, version); }