Skip to content

Commit

Permalink
feat(dictionary): add validator for dictionary
Browse files Browse the repository at this point in the history
  • Loading branch information
TomokiMiyauci committed May 22, 2023
1 parent 47bf837 commit b231f30
Showing 1 changed file with 5 additions and 5 deletions.
10 changes: 5 additions & 5 deletions validators/object.ts → validators/object/dictionary.ts
Original file line number Diff line number Diff line change
@@ -1,16 +1,16 @@
// Copyright 2023-latest Tomoki Miyauchi. All rights reserved. MIT license.
// This module is browser compatible.

import { map } from "../iter_utils.ts";
import { curryR, fromPath } from "../utils.ts";
import { map } from "../../iter_utils.ts";
import { curryR, fromPath } from "../../utils.ts";
import {
Assert,
AssertiveValidator,
Validation,
ValidationError,
} from "../types.ts";
} from "../../types.ts";

export class ObjectValidator<
export class DictionaryValidator<
const In extends Record<string, unknown>,
const In_ extends In = In,
> implements AssertiveValidator<In, In_> {
Expand All @@ -23,7 +23,7 @@ export class ObjectValidator<

*validate(input: In): Iterable<ValidationError> {
for (const [key, validator] of Object.entries(this.validators)) {
const value = input[key];
const value = input?.[key];
const iterable = validator.validate(value as never);

yield* map(iterable, curryR(fromPath, key));
Expand Down

0 comments on commit b231f30

Please sign in to comment.