/** * Validation error class * * Thrown when input validation fails, either client-side (Zod) * or server-side (API validation). */ import type { ZodError } from "zod"; import { ComplianceError } from "./base"; /** * A single validation issue */ export interface ValidationIssue { /** * Path to the field that failed validation. * Example: ["addresses", "0", "postalCode"] */ path: PropertyKey[]; /** * Human-readable error message */ message: string; /** * Validation rule that failed (optional) */ code?: string; } /** * Error thrown when input validation fails. * * Contains structured information about which fields failed * and why, making it easy to display errors in forms. * * @example * ```typescript * try { * await sdk.clients.create({ name: "" }); * } catch (error) { * if (error instanceof ValidationError) { * error.issues.forEach((issue) => { * console.log(`${issue.path.join(".")}: ${issue.message}`); * }); * } * } * ``` */ export declare class ValidationError extends ComplianceError { /** * List of validation issues */ readonly issues: ValidationIssue[]; constructor(issues: ValidationIssue[], requestId?: string); /** * Creates a ValidationError from a Zod error. * * @param error - Zod validation error * @param requestId - Optional request ID for tracing * @returns ValidationError with formatted issues */ static fromZodError(error: ZodError, requestId?: string): ValidationError; /** * Gets validation errors for a specific field path. * * @param path - Field path (e.g., "name" or "addresses.0.city") * @returns Array of error messages for the field * * @example * ```typescript * const nameErrors = error.getFieldErrors("name"); * // ["Name is required", "Name must be at least 2 characters"] * ``` */ getFieldErrors(path: string): string[]; /** * Checks if a specific field has validation errors. * * @param path - Field path to check * @returns True if the field has errors */ hasFieldError(path: string): boolean; /** * Gets a flat object of field paths to error messages. * Useful for form libraries. * * @returns Object mapping field paths to error messages * * @example * ```typescript * const fieldErrors = error.toFieldErrors(); * // { "name": "Name is required", "email": "Invalid email" } * ``` */ toFieldErrors(): Record; /** * Formats the validation issues into a human-readable message. */ private static formatMessage; }