(schema: S, input: I)
| 225 | * @since 4.0.0 |
| 226 | */ |
| 227 | export function asserts<S extends Schema.Constraint, I>(schema: S, input: I): asserts input is I & S["Type"] { |
| 228 | const ast = SchemaAST.toType(schema.ast) |
| 229 | const result = CompilerRegistry.resolve(ast).parser(input, SchemaAST.defaultParseOptions) |
| 230 | const exit = Effect.runSyncExit(parserResult<S["Type"], never>(result, input)) |
| 231 | if (Exit.isFailure(exit)) { |
| 232 | const issue = InternalSchemaCause.getSchemaIssueOrThrow( |
| 233 | exit.cause, |
| 234 | "Assertion adapter can only throw schema issues" |
| 235 | ) |
| 236 | throw new Error("Schema validation failed", { cause: issue }) |
| 237 | } |
| 238 | } |
| 239 | |
| 240 | /** |
| 241 | * Creates an effectful decoder for `unknown` input. |
nothing calls this directly
no test coverage detected