dilswer
Version:
Blazingly fast data validation library with TypeScript integration.
27 lines (26 loc) • 995 B
TypeScript
import type { AnyType } from "../data-types/type-types";
import { InferDType, ReWrap } from "../data-types/type-utils";
export interface FastValidator<T> {
(data: unknown): data is T;
asString(name?: string): string;
}
type CompileOptions = {
/**
* Overrides if the array/dict/sets helper functions should get inlined or not.
*
* By default these functions will get inlined only for some schemas, based on how deeply nested
* that schema is.
*/
inlineHelpers?: boolean;
};
/**
* Compile a validation function for the given data type.
*
* The compile function is extremely fast, but it is not possible
* to get detailed error messages from it.
*
* The compilation process takes a significant amount of time, so for the
* best performance, you should compile the validator ahead-of-time and reuse it.
*/
export declare const compile: <DT extends AnyType>(dataType: DT, options?: CompileOptions) => FastValidator<ReWrap<InferDType<DT>>>;
export {};