diff --git a/types/joi/index.d.ts b/types/joi/index.d.ts index c943fbfa33..35e386a928 100644 --- a/types/joi/index.d.ts +++ b/types/joi/index.d.ts @@ -209,6 +209,10 @@ export interface StringRegexOptions { invert?: boolean; } +export interface ArrayUniqueOptions { + ignoreUndefined?: boolean; +} + export interface JoiObject { isJoi: boolean; } @@ -762,7 +766,7 @@ export interface ArraySchema extends AnySchema { * Be aware that a deep equality is performed on elements of the array having a type of object, * a performance penalty is to be expected for this kind of operation. */ - unique(comparator?: string): this; + unique(comparator?: string, options?: ArrayUniqueOptions): this; unique(comparator?: (a: T, b: T) => boolean): this; } diff --git a/types/joi/joi-tests.ts b/types/joi/joi-tests.ts index b4f01cfe56..af232a269d 100644 --- a/types/joi/joi-tests.ts +++ b/types/joi/joi-tests.ts @@ -328,6 +328,7 @@ arrSchema = arrSchema.length(ref); arrSchema = arrSchema.unique(); arrSchema = arrSchema.unique((a, b) => a.test === b.test); arrSchema = arrSchema.unique('customer.id'); +arrSchema = arrSchema.unique('customer.id', {ignoreUndefined: true}); arrSchema = arrSchema.items(numSchema); arrSchema = arrSchema.items(numSchema, strSchema, schemaLike);