diff --git a/src/validators/object.ts b/src/validators/object.ts index 00f33d9..79d5ea2 100644 --- a/src/validators/object.ts +++ b/src/validators/object.ts @@ -32,9 +32,7 @@ export type PropertiesValidatorResult = { * console.assert(validator({ age: 15, name: 'Kim' }) === undefined) * ``` */ -export function object< - V extends ValidatorMap, ->( +export function object( validatorMap: V, ): Validator, PropertiesValidatorResult> { return function objectValidator(subject, context) { @@ -44,12 +42,10 @@ export function object< const errorEntries = Object .keys(validatorMap) - .map((key) => - [ - key, - validatorMap[key](subject[key], context), - ] as const - ) + .map((key) => ([ + key, + validatorMap[key](subject[key], context), + ] as const)) .filter(([_, errors]) => errors !== undefined); if (errorEntries.length === 0) { diff --git a/test/validators/all.test.ts b/test/validators/all.test.ts index ded92ed..b2155a0 100644 --- a/test/validators/all.test.ts +++ b/test/validators/all.test.ts @@ -1,5 +1,4 @@ import { all } from "../../src/validators/all.ts"; -import { object } from "../../src/validators/object.ts"; import { allItems, is, @@ -61,7 +60,7 @@ Deno.test("should correctly type check with multiple validators", () => { Deno.test("should merge complicated errors correctly", () => { const validator = all( requiredPrimitive("date required"), - (value: number) => { + () => { return ["other date error"]; }, );