import { type ObjectGroupNode, type RefsStore } from '@vinejs/compiler/types'; import { type GroupConditional } from './conditional.js'; import { ITYPE, OTYPE, COTYPE, PARSE } from '../../symbols.js'; import type { ParserOptions, UnionNoMatchCallback, WithJSONSchema } from '../../types.js'; import { type JSONSchema7 } from 'json-schema'; /** * ObjectGroup represents a collection of conditional property sets that can be * merged into an object based on runtime conditions. This enables dynamic schema * composition where different properties are validated based on conditional logic. * * @template Conditional - The type of conditional used in this group * * @example * const schema = vine.object({ * type: vine.string() * }).merge( * vine.group([ * vine.group.if((value) => value.type === 'user', { * username: vine.string() * }), * vine.group.if((value) => value.type === 'admin', { * permissions: vine.array(vine.string()) * }) * ]) * ) */ export declare class ObjectGroup> implements WithJSONSchema { #private; [ITYPE]: Conditional[typeof ITYPE]; [OTYPE]: Conditional[typeof OTYPE]; [COTYPE]: Conditional[typeof COTYPE]; /** * Creates a new ObjectGroup with the specified conditionals. * * @param conditionals - Array of conditional property sets to evaluate */ constructor(conditionals: Conditional[]); /** * Converts the object group to JSON Schema format using anyOf. * * @returns JSON Schema representation of this group */ toJSONSchema(): JSONSchema7; /** * Clones the ObjectGroup including all conditionals and the otherwise callback. * * @returns A cloned instance of this ObjectGroup */ clone(): this; /** * Defines a fallback callback to invoke when none of the group conditions match. * By default, this reports a validation error. Use this method to customize * the error handling behavior. * * @param callback - Callback to invoke when no condition matches * @returns This group instance for method chaining * * @example * vine.group([ * vine.group.if((value) => value.type === 'user', { username: vine.string() }), * vine.group.if((value) => value.type === 'admin', { role: vine.string() }) * ]).otherwise((value, field) => { * field.report('Invalid type specified', 'invalidType', field) * }) */ otherwise(callback: UnionNoMatchCallback>): this; /** * Compiles the group to a compiler node for validation. * * @param refs - Reference store for the compiler * @param options - Parser options * @returns Compiled object group node */ [PARSE](refs: RefsStore, options: ParserOptions): ObjectGroupNode; }