/** * Type guards, error helpers, and argument validators for the plugin. */ /** * Type guard to check if a value is defined (not null or undefined) * @param value - Value to check * @returns True if value is not null or undefined */ export declare function isDefined(value: T | null | undefined): value is T; /** * Type guard to check if a value is a non-empty string * @param value - Value to check * @returns True if value is a string with at least one non-whitespace character */ export declare function isNonEmptyString(value: unknown): value is string; /** * Coerce a finite numeric frontmatter value to its string form, mirroring how * Docusaurus (Joi `convert`) treats numeric `slug`/`id`/`title`. YAML parses an * unquoted `slug: 2025` as the number 2025, which would otherwise fail the * string guards and lose the numeric route. * @param value - Raw frontmatter value * @returns The value as a string when it is a finite number, otherwise unchanged */ export declare function coerceFrontMatterString(value: unknown): unknown; /** * Type guard to check if a value is a non-empty array * @param value - Value to check * @returns True if value is an array with at least one element */ export declare function isNonEmptyArray(value: unknown): value is T[]; /** * Safely extract an error message from an unknown error value * @param error - The error value (can be Error, string, or any other type) * @returns A string representation of the error */ export declare function getErrorMessage(error: unknown): string; /** * Extract stack trace from unknown error types * @param error - The error value (can be Error or any other type) * @returns Stack trace if available, undefined otherwise */ export declare function getErrorStack(error: unknown): string | undefined; /** * Custom error class for validation errors */ export declare class ValidationError extends Error { constructor(message: string); } /** * Validates that a value is not null or undefined * @param value - The value to validate * @param paramName - The parameter name for error messages * @returns The validated value * @throws ValidationError if the value is null or undefined */ export declare function validateRequired(value: T | null | undefined, paramName: string): T; /** * Validates that a value is a string and optionally checks its properties * @param value - The value to validate * @param paramName - The parameter name for error messages * @param options - Validation options for min/max length and pattern * @returns The validated string * @throws ValidationError if validation fails */ export declare function validateString(value: unknown, paramName: string, options?: { minLength?: number; maxLength?: number; pattern?: RegExp; }): string; /** * Validates that a value is an array and optionally validates elements * @param value - The value to validate * @param paramName - The parameter name for error messages * @param elementValidator - Optional function to validate each element * @returns The validated array * @throws ValidationError if validation fails */ export declare function validateArray(value: unknown, paramName: string, elementValidator?: (item: unknown) => boolean): T[];