UNPKG

groq-builder

Version:

A **schema-aware**, strongly-typed GROQ query builder. It enables you to build GROQ queries using **auto-completion**, **type-checking**, and **runtime validation**.

44 lines (43 loc) 1.28 kB
export type ErrorDetails = { /** * The path where the error occurred */ readonly path: PathSegment[]; /** * The actual (invalid) value */ readonly value: unknown; /** * The error message */ readonly message: string; }; /** * An error that represents a list of validation errors */ export declare class ValidationErrors extends TypeError { readonly errors: ErrorDetails[]; constructor(message?: string, errors?: ErrorDetails[]); /** * Adds a validation error to the list * * @param path - Relative path name for this error (eg. object key, array index) * @param value - Actual value at this path * @param error - The error - can be a ZodError, another ValidationError, or just any Error object */ add(path: PathSegment, value: unknown, error: Error): void; /** * Returns the number of validation errors */ get length(): number; /** * Returns the error with an updated message. * This ensures we don't calculate the message * until the error is ready to be thrown. * @example * if (validationErrors.length) throw validationErrors.withMessage() */ withMessage(): this; } type PathSegment = number | string | null; export {};