import { JsonSchemaResult, JsonSchemaTarget } from "../standard-schema/json-schema.mjs"; import { SchemaContext } from "../types/context-types.mjs"; import { ValidationResult } from "../types/result-types.mjs"; import { BaseValidator } from "./base-validator.mjs"; //#region ../@warlock.js/seal/src/validators/array-validator.d.ts /** * Array validator class */ declare class ArrayValidator extends BaseValidator { validator: BaseValidator; constructor(validator: BaseValidator, errorMessage?: string); /** * Check if value is an array type */ matchesType(value: any): boolean; /** * Clone the validator */ clone(): this; /** Reverse array order */ flip(): this; /** Reverse array order (alias) */ reverse(): this; /** Make it has only unique values */ onlyUnique(): this; /** Sort array */ sort(direction?: "asc" | "desc", key?: string): this; /** Array length must be greater than the given length */ minLength(length: number, errorMessage?: string): this; /** Array length must be less than the given length */ maxLength(length: number, errorMessage?: string): this; /** Array length must be of the given length */ length(length: number, errorMessage?: string): this; /** * Array length must be between min and max (inclusive) * * @param min - Minimum length (inclusive) * @param max - Maximum length (inclusive) * * @example * ```ts * v.array(v.string()).between(1, 10) // Array must have 1 to 10 items * v.array(v.number()).lengthBetween(5, 20) // Same using alias * ``` * * @category Validation Rule */ between(min: number, max: number, errorMessage?: string): this; /** * Alias for between() - array length between min and max */ lengthBetween(min: number, max: number, errorMessage?: string): this; /** Array must have unique values */ unique(errorMessage?: string): this; /** Array must be sorted */ sorted(direction?: "asc" | "desc", errorMessage?: string): this; /** Mutate the data */ mutate(data: any, context: SchemaContext): any; /** Validate array * * Absent input (and absent without `.default()`) propagates as `data: undefined` * so the parent ObjectValidator can omit the key. Without this, optional array * fields would silently materialise as `[]` in the validated output. */ validate(data: any, context: SchemaContext): Promise; /** * @inheritdoc * * Recursively generates JSON Schema for the array items. * * @example * ```ts * v.array(v.string().min(1)).minLength(1).toJsonSchema("draft-2020-12") * // → { type: "array", items: { type: "string", minLength: 1 }, minItems: 1 } * ``` */ toJsonSchema(target?: JsonSchemaTarget): JsonSchemaResult; } //#endregion export { ArrayValidator }; //# sourceMappingURL=array-validator.d.mts.map