From f390a5993680068fddd5be81af1738a05c3018b8 Mon Sep 17 00:00:00 2001 From: Jonathan Jayet Date: Fri, 10 Feb 2017 11:21:20 +0100 Subject: [PATCH 1/2] Added missing options to Joi.string().guid() --- joi/index.d.ts | 8 +++++++- 1 file changed, 7 insertions(+), 1 deletion(-) diff --git a/joi/index.d.ts b/joi/index.d.ts index 55e6b9c75f..bd78997932 100644 --- a/joi/index.d.ts +++ b/joi/index.d.ts @@ -91,6 +91,12 @@ export interface IpOptions { cidr?: string; } +export type GuidVersions = 'uuidv1' | 'uuidv2' | 'uuidv3' | 'uuidv4' | 'uuidv5' + +export interface GuidOptions { + version: GuidVersions[] +} + export interface UriOptions { /** * Specifies one or more acceptable Schemes, should only include the scheme name. @@ -443,7 +449,7 @@ export interface StringSchema extends AnySchema { /** * Requires the string value to be a valid GUID. */ - guid(): StringSchema; + guid(options?: GuidOptions): StringSchema; /** * Requires the string value to be a valid hexadecimal string. From 8ccf4f11564f7ab21882f7224adf407718249e74 Mon Sep 17 00:00:00 2001 From: Jonathan Jayet Date: Sat, 11 Feb 2017 11:59:55 +0100 Subject: [PATCH 2/2] Fixed missing option + added tests --- joi/index.d.ts | 2 +- joi/joi-tests.ts | 2 ++ 2 files changed, 3 insertions(+), 1 deletion(-) diff --git a/joi/index.d.ts b/joi/index.d.ts index bd78997932..fe1f0e39f8 100644 --- a/joi/index.d.ts +++ b/joi/index.d.ts @@ -94,7 +94,7 @@ export interface IpOptions { export type GuidVersions = 'uuidv1' | 'uuidv2' | 'uuidv3' | 'uuidv4' | 'uuidv5' export interface GuidOptions { - version: GuidVersions[] + version: GuidVersions[] | GuidVersions } export interface UriOptions { diff --git a/joi/joi-tests.ts b/joi/joi-tests.ts index 59eb446b2f..3a222ff832 100644 --- a/joi/joi-tests.ts +++ b/joi/joi-tests.ts @@ -691,6 +691,8 @@ strSchema = strSchema.ip(ipOpts); strSchema = strSchema.uri(); strSchema = strSchema.uri(uriOpts); strSchema = strSchema.guid(); +strSchema = strSchema.guid({version: ['uuidv1', 'uuidv2', 'uuidv3', 'uuidv4', 'uuidv5']}); +strSchema = strSchema.guid({version: 'uuidv4'}); strSchema = strSchema.hex(); strSchema = strSchema.hostname(); strSchema = strSchema.isoDate();