( parser: (input: E, options?: SchemaAST.ParseOptions) => Effect.Effect<T, SchemaIssue.Issue> )
| 946 | } |
| 947 | |
| 948 | function asPromise<T, E>( |
| 949 | parser: (input: E, options?: SchemaAST.ParseOptions) => Effect.Effect<T, SchemaIssue.Issue> |
| 950 | ): (input: E, options?: SchemaAST.ParseOptions) => Promise<T> { |
| 951 | return (input: E, options?: SchemaAST.ParseOptions) => |
| 952 | Effect.runPromiseExit(parser(input, options)).then((exit) => { |
| 953 | if (Exit.isSuccess(exit)) { |
| 954 | return exit.value |
| 955 | } |
| 956 | const issue = InternalSchemaCause.getSchemaIssueOrThrow( |
| 957 | exit.cause, |
| 958 | "Promise adapter can only reject schema issues" |
| 959 | ) |
| 960 | throw new Error("Schema validation failed", { cause: issue }) |
| 961 | }) |
| 962 | } |
| 963 | |
| 964 | function asExit<T, E, R>( |
| 965 | parser: (input: E, options?: SchemaAST.ParseOptions) => Effect.Effect<T, SchemaIssue.Issue, R> |
no outgoing calls
no test coverage detected