/** * Validation error containers mirroring ArkType's observable error surface: * `result instanceof type.errors` / `instanceof OmpErrors`, lazy `.summary`, * array iteration, and per-entry `.path` / `.problem` / `.message`. * * Failure-path cost matters: schemas reject untrusted input constantly, so * construction stores only the path, the expectation, and the offending value. * All human-readable strings are built lazily on property access. */ /** Context supplied to configurable error formatters. */ export interface ErrorContext { readonly code: string; readonly path: readonly PropertyKey[]; readonly propString: string; readonly data: unknown; readonly expected: string; readonly actual: string; readonly problem: string; readonly description: string; readonly rule?: unknown; } /** Per-schema overrides for validation error text. */ export interface ErrorConfig { readonly expected?: string | ((context: ErrorContext) => string); readonly actual?: string | ((data: unknown) => string); readonly problem?: string | ((context: ErrorContext) => string); readonly message?: string | ((context: ErrorContext) => string); /** Internal: custom predicate expectations display the offending value rather than its domain. */ readonly preserveActual?: boolean; } /** A single validation failure at one path. */ export declare class OmpError { #private; /** Property path from the root to the failing value (empty at root). */ readonly path: PropertyKey[]; /** The value that failed validation. */ readonly data: unknown; constructor( /** Property path from the root to the failing value (empty at root). */ path: PropertyKey[], expected: string, /** The value that failed validation. */ data: unknown, config?: ErrorConfig); /** Prefix this failure when a nested schema delegates validation. */ prefix(key: PropertyKey): this; /** Apply schema-local formatting to this failure. */ configure(config: ErrorConfig): this; /** Stable category for programmatic error handling. */ get code(): string; /** Human-readable expectation, including a configured override. */ get expected(): string; /** Short description of the received value, e.g. `"a number"` or `"missing"`. */ get actual(): string; /** Path-less problem statement: `must be (was )`. */ get problem(): string; get message(): string; toString(): string; } /** Sentinel for a required key that was absent (distinguishes from `undefined`). */ export declare const MISSING: unique symbol; /** * Validation failure result. The common single-error case remains lazy; * traversal only materializes an entry array when a second error is appended. */ type StoredPath = PropertyKey[] | PropertyKey | undefined; export declare class OmpErrors implements Iterable { #private; constructor(path: StoredPath, expected: string, data: unknown, config?: ErrorConfig); get length(): number; get 0(): OmpError; static single(path: PropertyKey[], expected: string, data: unknown, config?: ErrorConfig): OmpErrors; /** Append all failures from `other`, preserving traversal order. */ append(other: OmpErrors): this; /** Prefix every failure path with `key` when nesting sub-schemas. */ prefix(key: PropertyKey): this; /** Apply schema-local message formatting without rebuilding failures. */ configure(config: ErrorConfig): this; get byPath(): Readonly>; map(fn: (error: OmpError, index: number, errors: OmpErrors) => result): result[]; filter(fn: (error: OmpError, index: number, errors: OmpErrors) => unknown): OmpError[]; [Symbol.iterator](): IterableIterator; /** @internal Render multiple branch failures as alternatives rather than independent failures. */ asAlternatives(): this; get summary(): string; toString(): string; throw(): never; } /** Error thrown by `Type.assert` on invalid input. */ export declare class TraversalError extends Error { readonly errors: OmpErrors; constructor(errors: OmpErrors); } /** * Definition/usage error thrown while building a schema — malformed string * DSL, unsupported composition, or an illegal builder call. Distinct from * validation failures, which are returned as {@link OmpErrors}. */ export declare class OmpTypeError extends Error { constructor(message: string); } export {};