| 225 | // Errors built with nothing to find them, as a traversal's are, hold none |
| 226 | // until one is added |
| 227 | class UnreadIssues implements StandardSchemaV1.FailureResult, FailureContext { |
| 228 | declare _p: PropertyKey[] |
| 229 | /** @internal what finds its issues */ |
| 230 | declare _a: CompactApply | undefined |
| 231 | /** @internal the data they're found in */ |
| 232 | declare _d: unknown |
| 233 | /** @internal its issues, once found or added to */ |
| 234 | declare _f: ArkIssue[] | undefined |
| 235 | |
| 236 | constructor(data?: unknown, config?: unknown, apply?: CompactApply) { |
| 237 | this._p = [] |
| 238 | this._a = apply |
| 239 | this._d = data |
| 240 | } |
| 241 | |
| 242 | /** @internal each issue in the order it was added, found when first read */ |
| 243 | get _(): ArkIssue[] { |
| 244 | if (!this._f) { |
| 245 | this._f = [] |
| 246 | // data a write or a getter has made valid since fails as a whole |
| 247 | if (this._a && (this._a(this._d, this), !this._f.length)) |
| 248 | this._e(this._d, "predicate", "valid", "is invalid") |
| 249 | } |
| 250 | return this._f |
| 251 | } |
| 252 | |
| 253 | get count(): number { |
| 254 | return this._.length |
| 255 | } |
| 256 | |
| 257 | get issues(): readonly WrittenIssue[] { |
| 258 | return readsIssues ? serializableIssues(this._) : (this._ as WrittenIssue[]) |
| 259 | } |
| 260 | |
| 261 | _e( |
| 262 | data: unknown, |
| 263 | code: ArkErrorCode, |
| 264 | expected?: string, |
| 265 | message?: string, |
| 266 | text?: SiteContext["text"] |
| 267 | ): true | undefined { |
| 268 | this._.push({ code, path: this._p.slice(), data, expected, message }) |
| 269 | if (callsSiteText) text?.(this._[this._.length - 1]) |
| 270 | return undefined |
| 271 | } |
| 272 | |
| 273 | _k( |
| 274 | apply: CompactApply, |
| 275 | data: unknown, |
| 276 | key: PropertyKey, |
| 277 | ...missing: MissingText |
| 278 | ): boolean | undefined { |
| 279 | this._p.push(key) |
| 280 | const stops = |
| 281 | missing.length && !(key in (data as object)) ? |
| 282 | this._e(data, "required", ...missing) |
| 283 | : !apply((data as Keyed)[key], this) |
| 284 | this._p.pop() |
nothing calls this directly
no outgoing calls
no test coverage detected