(schema: Schema.Schema<A, I, R>, options?: AST.ParseOptions)
| 675 | * @since 3.10.0 |
| 676 | */ |
| 677 | export const asserts = <A, I, R>(schema: Schema.Schema<A, I, R>, options?: AST.ParseOptions) => { |
| 678 | const parser = goMemo(AST.typeAST(schema.ast), true) |
| 679 | return (u: unknown, overrideOptions?: AST.ParseOptions): asserts u is A => { |
| 680 | const result: Either.Either<any, ParseIssue> = parser(u, { |
| 681 | exact: true, |
| 682 | ...mergeInternalOptions(options, overrideOptions) |
| 683 | }) as any |
| 684 | if (Either.isLeft(result)) { |
| 685 | throw parseError(result.left) |
| 686 | } |
| 687 | } |
| 688 | } |
| 689 | |
| 690 | /** |
| 691 | * @category encoding |
no test coverage detected