| 160 | * ArkError intersection. |
| 161 | */ |
| 162 | export class ArkErrors |
| 163 | extends ReadonlyArray<ArkError> |
| 164 | implements StandardSchemaV1.FailureResult |
| 165 | { |
| 166 | readonly [arkKind] = "errors" |
| 167 | |
| 168 | /** |
| 169 | * Inherited array methods (`map`, `filter`, `slice`, …) return a plain |
| 170 | * `Array`, not another `ArkErrors`, so callbacks that return primitives |
| 171 | * (e.g. `issues.map(i => i.message)`) cannot populate a new `ArkErrors` instance. |
| 172 | */ |
| 173 | static get [Symbol.species](): ArrayConstructor { |
| 174 | return Array |
| 175 | } |
| 176 | |
| 177 | protected ctx: Traversal |
| 178 | |
| 179 | constructor(ctx: Traversal) { |
| 180 | super() |
| 181 | this.ctx = ctx |
| 182 | } |
| 183 | |
| 184 | /** |
| 185 | * Errors by a pathString representing their location. |
| 186 | */ |
| 187 | byPath: Record<string, ArkError> = Object.create(null) |
| 188 | |
| 189 | /** |
| 190 | * {@link byPath} flattened so that each value is an array of ArkError instances at that path. |
| 191 | * |
| 192 | * ✅ Since "intersection" errors will be flattened to their constituent `.errors`, |
| 193 | * they will never be directly present in this representation. |
| 194 | */ |
| 195 | get flatByPath(): Record<string, ArkError[]> { |
| 196 | return flatMorph(this.byPath, (k, v) => [k, v.flat]) |
| 197 | } |
| 198 | |
| 199 | /** |
| 200 | * {@link byPath} flattened so that each value is an array of problem strings at that path. |
| 201 | */ |
| 202 | get flatProblemsByPath(): Record<string, string[]> { |
| 203 | return flatMorph(this.byPath, (k, v) => [k, v.flat.map(e => e.problem)]) |
| 204 | } |
| 205 | |
| 206 | /** |
| 207 | * All pathStrings at which errors are present mapped to the errors occuring |
| 208 | * at that path or any nested path within it. |
| 209 | */ |
| 210 | byAncestorPath: Record<string, ArkError[]> = Object.create(null) |
| 211 | |
| 212 | count = 0 |
| 213 | private mutable: ArkError[] = this as never |
| 214 | |
| 215 | /** |
| 216 | * Throw a TraversalError based on these errors. |
| 217 | */ |
| 218 | throw(): never { |
| 219 | throw this.toTraversalError() |
nothing calls this directly
no outgoing calls
no test coverage detected
searching dependent graphs…