import type { Validator } from '@stacksjs/ts-validation'; /** * Mixin: add `.when()` / `.sometimes()` to a validator instance. * * Mutates the validator in place (assigning the new methods) so the * existing chainable surface (`.required()`, `.minLength()`, etc.) * keeps returning `this`. Returns the same instance with the augmented * type so callers see the new methods on the fluent chain. */ export declare function withConditionals>(validator: V): V & ConditionalAPI; /** * Evaluate a single `when` clause against a parent object. * * Returns `true` when the conditional should fire (and its refinement * should be applied). Pure function — no side effects, safe to call * during introspection too. */ export declare function shouldApplyConditional(record: ConditionalRecord>, parent: Record | null | undefined): boolean; /** * Apply every matching conditional on `base` against `parent`, in * registration order. Returns the (possibly refined) validator that * should be used to validate the field. * * The base validator is NEVER mutated — ts-validation methods like * `.required()` and `.min(3)` MUTATE `this` and return it, so calling * refine functions directly on the base would leak across `validate()` * invocations (each call would compound the previous refinements, * making "VAT required for EU customers" sticky across requests). * {@link cloneValidator} produces an isolated instance the refine * pipeline can safely mutate without polluting the schema definition. */ export declare function applyConditionals>(base: V, parent: Record | null | undefined): V; /** * A single `.when()` clause attached to a field validator. Multiple * `.when()` calls stack — they're evaluated in registration order and * each matching one further refines the base validator. */ export declare interface ConditionalRecord> { field: string match: unknown | ((value: unknown) => boolean) refine: (validator: V) => V } /** Anything that has a mutable conditionals array — duck-typed so this * works across all the ts-validation validator subclasses. */ export declare interface ValidatorWithConditionals> { __conditionals?: ConditionalRecord[] } /** * Conditional-rules surface — apps reach these methods through * `.when()` / `.sometimes()` on any validator the schema proxy returns. */ export declare interface ConditionalAPI> { when: ( field: string, match: unknown | ((value: unknown) => boolean), refine: (validator: V) => V, ) => V & ConditionalAPI sometimes: () => V & ConditionalAPI }