-
Notifications
You must be signed in to change notification settings - Fork 1
/
Copy pathindex.d.ts
35 lines (31 loc) · 914 Bytes
/
index.d.ts
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
type onFailure = 'ignore' | 'setNull';
export interface PropertyCheckParams {
type?: any;
arrayType?: any;
required?: boolean;
nullable?: boolean;
onFailure?: onFailure;
customValidator?: (input: any) => boolean;
}
export declare enum ValidationErrorType {
NullValue = 'null',
MissingField = 'missing',
InvalidType = 'invalid',
}
export class ValidationError extends Error {
public readonly field: string | undefined;
public readonly errorType: ValidationErrorType;
}
export function TypesCheck(
target: any,
propertyKey: string,
descriptor: TypedPropertyDescriptor<any>
): any;
export function TypeCheck(type: any): any;
export function PropertyCheck(params?: PropertyCheckParams): any;
export function validate<T>(input: any, expectedType: new () => T): T;
export function validate<T extends ArrayConstructor, U>(
input: any,
expectedType: T,
arrayType: new () => U
): U[];