@jkcfg/std
Version:
jk standard library
27 lines (26 loc) • 778 B
TypeScript
/**
* @module std/validation
*/
interface Location {
line: number;
column: number;
}
/**
* ValidationError represents a specific problem encountered when
* validating a value.
*/
export interface ValidationError {
msg: string;
path?: string;
start?: Location;
end?: Location;
}
export declare type ValidationResult = 'ok' | ValidationError[];
export declare type ValidateFnResult = boolean | string | (string | ValidationError)[];
export declare function normaliseResult(result: ValidateFnResult): ValidationResult;
/**
* formatError formats a validation error in a standard way. Since the
* errors do not include the source, this must be supplied.
*/
export declare function formatError(source: string, err: ValidationError): string;
export {};