fix: Added Unique Array options.

This commit is contained in:
Ernie Casilla
2019-04-14 09:58:33 -04:00
parent d8748201c7
commit 31015de2f7
2 changed files with 6 additions and 1 deletions
+5 -1
View File
@@ -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<T = any>(comparator?: (a: T, b: T) => boolean): this;
}
+1
View File
@@ -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);