import { type RefsStore, type ArrayNode } from '@vinejs/compiler/types'; import { BaseType } from '../base/main.js'; import { type ITYPE, type OTYPE, type COTYPE, PARSE, UNIQUE_NAME, IS_OF_TYPE } from '../../symbols.js'; import type { FieldOptions, ParserOptions, SchemaTypes, Validation, WithJSONSchema } from '../../types.js'; import { type JSONSchema7 } from 'json-schema'; /** * VineArray represents an array schema type in the validation pipeline. * It validates arrays and their elements using a nested schema, with support * for length constraints, uniqueness checks, and element filtering. * * @template Schema - The schema type for validating array elements * * @example * const schema = vine.array(vine.string().email()) * .minLength(1) * .maxLength(10) * .distinct() * * const result = await vine.validate({ * schema, * data: ['user1@example.com', 'user2@example.com'] * }) */ export declare class VineArray extends BaseType implements WithJSONSchema { #private; /** * Static collection of all available validation rules for arrays */ static rules: { compact: (options?: undefined) => Validation; notEmpty: (options?: undefined) => Validation; distinct: (options: { fields?: string | string[]; }) => Validation<{ fields?: string | string[]; }>; minLength: (options: { min: number; }) => Validation<{ min: number; }>; maxLength: (options: { max: number; }) => Validation<{ max: number; }>; fixedLength: (options: { size: number; }) => Validation<{ size: number; }>; }; /** * Unique name identifier for union type resolution */ [UNIQUE_NAME]: string; /** * Type checker function to determine if a value is an array. * Required for "unionOfTypes" functionality. * * @param value - The value to check * @returns True if the value is an array */ [IS_OF_TYPE]: (value: unknown) => value is any[]; /** * Creates a new VineArray instance with element schema and optional configuration. * * @param schema - The schema to validate each array element * @param options - Field options like bail mode and nullability * @param validations - Initial set of validations to apply */ constructor(schema: Schema, options?: FieldOptions, validations?: Validation[]); /** * Enforce a minimum length on an array field. * * @param expectedLength - The minimum required number of elements * @returns This array schema instance for method chaining */ minLength(expectedLength: number): this; /** * Enforce a maximum length on an array field. * * @param expectedLength - The maximum allowed number of elements * @returns This array schema instance for method chaining */ maxLength(expectedLength: number): this; /** * Enforce a fixed length on an array field. * * @param expectedLength - The exact required number of elements * @returns This array schema instance for method chaining */ fixedLength(expectedLength: number): this; /** * Ensure the array is not empty. * * @returns This array schema instance for method chaining */ notEmpty(): this; /** * Ensure array elements are distinct/unique. * * @param fields - Optional field names to check for uniqueness in object arrays * @returns This array schema instance for method chaining */ distinct(fields?: string | string[]): this; /** * Removes empty strings, null and undefined values from the array. * * @returns This array schema instance for method chaining */ compact(): this; /** * Clones the VineArray schema type. The applied options * and validations are copied to the new instance. * * @returns A cloned instance of this VineArray schema */ clone(): this; /** * Transforms into JSONSchema. */ toJSONSchema(): JSONSchema7; /** * Compiles to array data type for the validation compiler. * * @param propertyName - Name of the property being compiled * @param refs - Reference store for the compiler * @param options - Parser options * @returns Compiled array node for validation */ [PARSE](propertyName: string, refs: RefsStore, options: ParserOptions): ArrayNode; }