Skip to content

Commit

Permalink
:rotatings_light:
Browse files Browse the repository at this point in the history
  • Loading branch information
reckter committed Sep 22, 2022
1 parent 56528f1 commit 208dd0d
Show file tree
Hide file tree
Showing 2 changed files with 6 additions and 11 deletions.
14 changes: 5 additions & 9 deletions src/validators/object.ts
Original file line number Diff line number Diff line change
Expand Up @@ -32,9 +32,7 @@ export type PropertiesValidatorResult<V extends ValidatorMap> = {
* console.assert(validator({ age: 15, name: 'Kim' }) === undefined)
* ```
*/
export function object<
V extends ValidatorMap,
>(
export function object<V extends ValidatorMap>(
validatorMap: V,
): Validator<PropertiesValidatorInput<V>, PropertiesValidatorResult<V>> {
return function objectValidator(subject, context) {
Expand All @@ -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) {
Expand Down
3 changes: 1 addition & 2 deletions test/validators/all.test.ts
Original file line number Diff line number Diff line change
@@ -1,5 +1,4 @@
import { all } from "../../src/validators/all.ts";
import { object } from "../../src/validators/object.ts";
import {
allItems,
is,
Expand Down Expand Up @@ -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"];
},
);
Expand Down

0 comments on commit 208dd0d

Please sign in to comment.