| 4036 | |
| 4037 | /** @internal */ |
| 4038 | export function collectIssues<T>( |
| 4039 | checks: ReadonlyArray<Check<T>>, |
| 4040 | value: T, |
| 4041 | issues: Arr.NonEmptyArray<SchemaIssue.Issue> | undefined, |
| 4042 | ast: AST, |
| 4043 | options: ParseOptions |
| 4044 | ): Arr.NonEmptyArray<SchemaIssue.Issue> | undefined { |
| 4045 | for (let i = 0; i < checks.length; i++) { |
| 4046 | const check = checks[i] |
| 4047 | if (check._tag === "FilterGroup") { |
| 4048 | issues = collectIssues(check.checks, value, issues, ast, options) |
| 4049 | if ( |
| 4050 | issues && |
| 4051 | (options.errors !== "all" || (issues[issues.length - 1] as SchemaIssue.Filter).filter.aborted) |
| 4052 | ) { |
| 4053 | return issues |
| 4054 | } |
| 4055 | } else { |
| 4056 | const issue = check.run(value, ast, options) |
| 4057 | if (issue) { |
| 4058 | const filter = new SchemaIssue.Filter(check, issue, value, options) |
| 4059 | if (issues) issues.push(filter) |
| 4060 | else issues = [filter] |
| 4061 | if (options.errors !== "all" || check.aborted) { |
| 4062 | return issues |
| 4063 | } |
| 4064 | } |
| 4065 | } |
| 4066 | } |
| 4067 | return issues |
| 4068 | } |
| 4069 | |
| 4070 | /** @internal */ |
| 4071 | export function runChecks<T>( |