@code-pushup/models
Version:
Model definitions and validators for the Code PushUp CLI
31 lines (30 loc) • 1.43 kB
TypeScript
import { ZodError, type ZodType, z } from 'zod';
/**
* Type Definition: `SchemaValidationContext`
*
* This type is derived from a Zod schema and represents
* the validated structure of `SchemaValidationContext` used within the application.
*
* @see {@link https://github.com/code-pushup/cli/blob/main/packages/models/docs/models-reference.md#schemavalidationcontext}
*/
type SchemaValidationContext = {
filePath?: string;
};
/**
* Autocompletes valid Zod Schema input for convience, but will accept any other data as well
*/
/**
* Type Definition: `ZodInputLooseAutocomplete`
*
* This type is derived from a Zod schema and represents
* the validated structure of `ZodInputLooseAutocomplete` used within the application.
*
* @see {@link https://github.com/code-pushup/cli/blob/main/packages/models/docs/models-reference.md#zodinputlooseautocomplete}
*/
type ZodInputLooseAutocomplete<T extends ZodType> = z.input<T> | {} | null | undefined;
export declare class SchemaValidationError extends Error {
constructor(error: ZodError, schema: ZodType, { filePath }: SchemaValidationContext);
}
export declare function validate<T extends ZodType>(schema: T, data: ZodInputLooseAutocomplete<T>, context?: SchemaValidationContext): z.output<T>;
export declare function validateAsync<T extends ZodType>(schema: T, data: ZodInputLooseAutocomplete<T>, context?: SchemaValidationContext): Promise<z.output<T>>;
export {};