import type { ConditionalAPI } from './conditional'; import type { ValidationResult, Validator } from '@stacksjs/ts-validation'; /** * Build a Stacks-flavored object validator that respects conditional * rules on its child validators. Drop-in for `v.object(...)` in * `@stacksjs/ts-validation` — same call shape, broader behavior. * * @example * ```ts * objectWithContext({ * payment_method: schema.enum(['card', 'bank']), * card_token: schema.string().when('payment_method', 'card', s => s.required()), * bank_account: schema.string().when('payment_method', 'bank', s => s.required()), * username: schema.string().sometimes().minLength(3), * }).validate(input) * ``` */ export declare function objectWithContext>(initialShape?: TShape): ObjectWithContextValidator & ConditionalAPI>; export declare interface ObjectWithContextValidator extends Validator> { readonly name: 'object' validate: (value: InferObjectShape) => ValidationResult getShape: () => TShape required: () => this optional: () => this isPartOfShape: boolean shape: (shape: TNextShape) => ObjectWithContextValidator } /** * Validator-shaped object returned by `schema.object()`. Mirrors the * subset of ts-validation's `ObjectValidatorType` that Stacks code * actually uses today (`validate`, `shape`, `optional`, `required`). * * Extra method: * - `getShape()` — exposes the underlying shape map so OpenAPI export * and other introspection passes can walk the per-field validators * (and their `__conditionals` arrays). */ export type ValidatorShape = Readonly>>; /** Resolve the value accepted by one validator. */ export type InferValidatorValue = TValidator extends Validator ? TValue : never; /** Resolve an object value directly from its validator shape. */ export type InferObjectShape = { -readonly [TKey in keyof TShape]: InferValidatorValue }