| 2213 | * |
| 2214 | * **Gotchas** |
| 2215 | * |
| 2216 | * Non-schema failures may reject with a runtime failure instead of |
| 2217 | * `SchemaError`. |
| 2218 | * |
| 2219 | * @see {@link SchemaParser.encodeUnknownPromise} for the adapter that rejects with an `Error` whose cause is `SchemaIssue.Issue` |
| 2220 | * |
| 2221 | * @category encoding |
| 2222 | * @since 3.10.0 |
| 2223 | */ |
| 2224 | export function encodeUnknownPromise<S extends ConstraintEncoder<unknown>>( |
| 2225 | schema: S, |
| 2226 | options?: SchemaAST.ParseOptions |
| 2227 | ) { |
| 2228 | const parser = encodeUnknownEffect(schema, options) |
| 2229 | return (input: unknown, options?: SchemaAST.ParseOptions): Promise<S["Encoded"]> => { |
| 2230 | return runSchemaErrorPromise(parser(input, options)) |
| 2231 | } |
| 2232 | } |
| 2233 | |
| 2234 | /** |
| 2235 | * Encodes a typed input (the schema's `Type`) against a schema, returning a |
| 2236 | * `Promise` that resolves with the encoded value or rejects with a |
| 2237 | * {@link SchemaError} for schema mismatches. |
| 2238 | * |
no outgoing calls
no test coverage detected
searching dependent graphs…