Skip to content

Commit 1f63435

Browse files
committed
Merge branch 'release/0.5.2'
2 parents aaff589 + 5bbbf46 commit 1f63435

File tree

3 files changed

+11
-4
lines changed

3 files changed

+11
-4
lines changed

lib/index.ts

Lines changed: 9 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -338,10 +338,17 @@ export function isObject(next?: (arg: any) => any): (arg: any) => any {
338338

339339

340340
export function conformsTo<T>(validator: Validator<T>): (arg: any) => Validated<T>;
341+
export function conformsTo<T>(validator: Validator<T>, options: IValidationOptions): (arg: any) => Validated<T>;
341342
export function conformsTo<T,U>(validator: Validator<T>, next: (arg: Validated<T>) => U): (arg: any) => U;
342-
export function conformsTo<T>(validator: Validator<T>, next?: (arg: Validated<T>) => any): (arg: any) => any {
343+
export function conformsTo<T,U>(validator: Validator<T>, options: IValidationOptions, next: (arg: Validated<T>) => U): (arg: any) => U;
344+
export function conformsTo<T>(validator: Validator<T>, optionsOrNext?: IValidationOptions | ((arg: Validated<T>) => any), next?: (arg: Validated<T>) => any): (arg: any) => any {
343345
return (arg: any) => {
344-
let validated = validate(arg, validator);
346+
if (typeof optionsOrNext === 'function') {
347+
next = optionsOrNext;
348+
}
349+
350+
const validated = validate(arg, validator, typeof optionsOrNext === 'object' ? optionsOrNext : undefined);
351+
345352
return next ? next(validated) : validated;
346353
};
347354
}

package-lock.json

Lines changed: 1 addition & 1 deletion
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

package.json

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
{
22
"name": "validate-interface",
3-
"version": "0.5.1",
3+
"version": "0.5.2",
44
"description": "Validate Objects Against TypeScript Interfaces",
55
"main": "dist/index.js",
66
"types": "dist/index.d.ts",

0 commit comments

Comments
 (0)