/** * Custom error class for application-level errors with detailed context. * Extends the built-in Error class to provide additional metadata. */ export declare class AppError extends Error { /** Error code for programmatic handling */ readonly code: string; /** Additional context about the error */ readonly context?: Record; /** * Creates a new AppError instance. * * @param message - Human-readable error message * @param code - Error code for programmatic handling * @param context - Optional additional context */ constructor(message: string, code: string, context?: Record); } /** * Validates that a string is valid JSON and parses it. * * Uses zod for runtime validation to ensure the input is a valid string * before attempting to parse. The parsed result is then validated * against a permissive schema that accepts any valid JSON value. * * @param input - The string to validate and parse as JSON * @returns The parsed JSON value (object, array, string, number, boolean, or null) * @throws AppError with code 'INVALID_JSON' if the string is not valid JSON * * @example * ```typescript * // Parse a valid JSON object * const obj = validateAndParseJSON('{"name": "test", "value": 42}'); * // Returns: { name: "test", value: 42 } * * // Parse a valid JSON array * const arr = validateAndParseJSON('[1, 2, 3]'); * // Returns: [1, 2, 3] * * // Invalid JSON throws AppError * try { * validateAndParseJSON('{invalid}'); * } catch (error) { * if (error instanceof AppError) { * console.log(error.code); // 'INVALID_JSON' * } * } * ``` */ export declare function validateAndParseJSON(input: string): unknown; //# sourceMappingURL=validate-json.d.ts.map