| 151 | |
| 152 | /** @internal */ |
| 153 | export function _is<T>(ast: SchemaAST.AST) { |
| 154 | const parser = asExit(run<T, never>(SchemaAST.toType(ast))) |
| 155 | return <I>(input: I): input is I & T => { |
| 156 | const exit = parser(input, SchemaAST.defaultParseOptions) |
| 157 | if (Exit.isSuccess(exit)) { |
| 158 | return true |
| 159 | } |
| 160 | InternalSchemaCause.getSchemaIssueOrThrow(exit.cause, "Type guard adapter can only return false for schema issues") |
| 161 | return false |
| 162 | } |
| 163 | } |
| 164 | |
| 165 | /** @internal */ |
| 166 | export function _issue<T>(ast: SchemaAST.AST) { |