1 | import { IAnyType, ExtractCSTWithSTN } from "../../internal";
|
2 | /** Validation context entry, this is, where the validation should run against which type */
|
3 | export interface IValidationContextEntry {
|
4 | /** Subpath where the validation should be run, or an empty string to validate it all */
|
5 | path: string;
|
6 | /** Type to validate the subpath against */
|
7 | type: IAnyType;
|
8 | }
|
9 | /** Array of validation context entries */
|
10 | export declare type IValidationContext = IValidationContextEntry[];
|
11 | /** Type validation error */
|
12 | export interface IValidationError {
|
13 | /** Validation context */
|
14 | context: IValidationContext;
|
15 | /** Value that was being validated, either a snapshot or an instance */
|
16 | value: any;
|
17 | /** Error message */
|
18 | message?: string;
|
19 | }
|
20 | /** Type validation result, which is an array of type validation errors */
|
21 | export declare type IValidationResult = IValidationError[];
|
22 | /**
|
23 | * Run's the typechecker for the given type on the given value, which can be a snapshot or an instance.
|
24 | * Throws if the given value is not according the provided type specification.
|
25 | * Use this if you need typechecks even in a production build (by default all automatic runtime type checks will be skipped in production builds)
|
26 | *
|
27 | * @param type Type to check against.
|
28 | * @param value Value to be checked, either a snapshot or an instance.
|
29 | */
|
30 | export declare function typecheck<IT extends IAnyType>(type: IT, value: ExtractCSTWithSTN<IT>): void;
|