@gati-framework/runtime
Version:
Gati runtime execution engine for running handler-based applications
95 lines • 2.33 kB
TypeScript
/**
* @module runtime/gtype/errors
* @description Validation error types and formatting
*/
import type { GType } from './schema.js';
/**
* Validation error path segment
*/
export type PathSegment = string | number;
/**
* Validation error details
*/
export interface ValidationError {
/**
* Path to the field that failed validation
*/
path: PathSegment[];
/**
* Expected type or constraint
*/
expected: string;
/**
* Actual value received
*/
actual: unknown;
/**
* Error message
*/
message: string;
/**
* GType that was being validated against
*/
schema?: GType;
}
/**
* Validation result
*/
export interface ValidationResult {
/**
* Whether validation passed
*/
valid: boolean;
/**
* List of validation errors (empty if valid)
*/
errors: ValidationError[];
}
/**
* Create a validation error
*/
export declare function createValidationError(path: PathSegment[], expected: string, actual: unknown, message?: string, schema?: GType): ValidationError;
/**
* Format a value for error messages
*/
export declare function formatValue(value: unknown): string;
/**
* Format a path for error messages
*/
export declare function formatPath(path: PathSegment[]): string;
/**
* Format validation errors for display
*/
export declare function formatValidationErrors(errors: ValidationError[]): string;
/**
* Create a successful validation result
*/
export declare function validResult(): ValidationResult;
/**
* Create a failed validation result
*/
export declare function invalidResult(errors: ValidationError[]): ValidationResult;
/**
* Merge multiple validation results
*/
export declare function mergeResults(...results: ValidationResult[]): ValidationResult;
/**
* Validation exception
*/
export declare class ValidationException extends Error {
errors: ValidationError[];
constructor(errors: ValidationError[], message?: string);
/**
* Get formatted error message
*/
getFormattedErrors(): string;
/**
* Get errors for a specific path
*/
getErrorsForPath(path: PathSegment[]): ValidationError[];
/**
* Check if a specific path has errors
*/
hasErrorsForPath(path: PathSegment[]): boolean;
}
//# sourceMappingURL=errors.d.ts.map