Skip to content

Commit

Permalink
feat(utils): impl toString method
Browse files Browse the repository at this point in the history
  • Loading branch information
TomokiMiyauci committed May 26, 2023
1 parent a44d149 commit 9069e2a
Showing 1 changed file with 6 additions and 2 deletions.
8 changes: 6 additions & 2 deletions utils.ts
Original file line number Diff line number Diff line change
Expand Up @@ -182,13 +182,17 @@ export function lazy<In, A extends In = In>(
fn: () => Validator<In, A>,
): Validator<In, A> {
const $fn = memoize(fn);

return {
const validator = {
is: (input: In): input is A => {
return $fn().is(input);
},
*validate(input: In): Iterable<ValidationFailure> {
yield* $fn().validate(input);
},
toString(): string {
return `${$fn()}`;
},
};

return validator;
}

0 comments on commit 9069e2a

Please sign in to comment.