Skip to content

Commit

Permalink
feat: add all option in isuuid validator (#452)
Browse files Browse the repository at this point in the history
  • Loading branch information
rubiin authored and vlapo committed Nov 11, 2019
1 parent f7a46ab commit 98e9382
Show file tree
Hide file tree
Showing 3 changed files with 4 additions and 4 deletions.
4 changes: 2 additions & 2 deletions README.md
Expand Up @@ -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.
Expand Down Expand Up @@ -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. |
Expand Down
2 changes: 1 addition & 1 deletion src/decorator/decorators.ts
Expand Up @@ -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,
Expand Down
2 changes: 1 addition & 1 deletion src/validation/Validator.ts
Expand Up @@ -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);
}

Expand Down

0 comments on commit 98e9382

Please sign in to comment.