/** * SSoT input validator over {@link OperationInputContract}. * * This module is the SINGLE SOURCE OF TRUTH for validating raw operation * payloads against the schema-first {@link OperationInputContract} surface * introduced by T9914. It powers the `mutate(operation, input)` DX (Saga * T9855 / E7) and feeds into the CLI transport adapter (T9916) plus every * future per-operation retrofit (T9917+). * * Implementation notes: * - Uses AJV draft-07 with `allErrors: true` so callers get every failure * in a single pass — never bail on the first. * - Caches compiled validators in a Map keyed by `contract.operation` * because re-compiling AJV per invocation is the dominant hot-path cost. * - Maps AJV errors into the wire-stable {@link ValidationError} shape with * JSON Pointer paths, per-keyword human-readable expected/received/fix * text, stable `E_VAL_` codes, and `x-fix-hint` overrides walked * off the contract schema by `schemaPath`. * * @packageDocumentation * @module @cleocode/core/dispatch/validation * * @epic T9855 * @task T9915 */ import type { OperationInputContract, ValidationResult } from '@cleocode/contracts'; /** * Reset the compiled-validator cache. Intended for tests that want to * assert AJV compilation behaviour across runs; production callers should * never need this. * * @internal */ export declare function _resetValidationCache(): void; /** * Validate a raw operation payload against an {@link OperationInputContract} * and return a strongly-typed {@link ValidationResult}. * * On success the result is `{ ok: true, value: rawInput as T }` — the * validator does NOT clone or coerce the payload, it only narrows the * type. On failure the result is `{ ok: false, errors: ValidationError[] }` * with one entry per AJV error (AJV is configured with `allErrors: true` * so callers see every problem in one pass). * * Compiled AJV validators are cached by `contract.operation` — the hot * path therefore avoids re-compilation entirely. * * @typeParam T - The validated input shape produced on success. * @param contract - Schema-first input contract (see T9914). * @param rawInput - Raw, untrusted payload to validate. * @returns Discriminated {@link ValidationResult} narrowed on `ok`. * * @example * ```ts * const result = validateOperationInput(createTaskContract, payload); * if (result.ok) { * await dispatch.tasks.create(result.value); * } else { * for (const e of result.errors) console.error(`${e.path}: ${e.fix}`); * } * ``` * * @epic T9855 * @task T9915 */ export declare function validateOperationInput(contract: OperationInputContract, rawInput: unknown): ValidationResult; //# sourceMappingURL=validation.d.ts.map