( parser: (input: E, options?: SchemaAST.ParseOptions) => Effect.Effect<T, SchemaIssue.Issue> )
| 999 | } |
| 1000 | |
| 1001 | function asPromise<T, E>( |
| 1002 | parser: (input: E, options?: SchemaAST.ParseOptions) => Effect.Effect<T, SchemaIssue.Issue> |
| 1003 | ): (input: E, options?: SchemaAST.ParseOptions) => Promise<T> { |
| 1004 | return (input: E, options?: SchemaAST.ParseOptions) => |
| 1005 | Effect.runPromiseExit(parser(input, options)).then((exit) => { |
| 1006 | if (Exit.isSuccess(exit)) { |
| 1007 | return exit.value |
| 1008 | } |
| 1009 | const issue = InternalSchemaCause.getSchemaIssueOrThrow( |
| 1010 | exit.cause, |
| 1011 | "Promise adapter can only reject schema issues" |
| 1012 | ) |
| 1013 | throw new Error("Schema validation failed", { cause: issue }) |
| 1014 | }) |
| 1015 | } |
| 1016 | |
| 1017 | function asExit<T, E, R>( |
| 1018 | parser: (input: E, options?: SchemaAST.ParseOptions) => Effect.Effect<T, SchemaIssue.Issue, R> |
no test coverage detected