UNPKG

1.7 kBTypeScriptView Raw
1import { ValidationError } from './ValidationError';
2import { ValidatorOptions } from './ValidatorOptions';
3/**
4 * Validator performs validation of the given object based on its metadata.
5 */
6export declare class Validator {
7 /**
8 * Performs validation of the given object based on decorators used in given object class.
9 */
10 validate(object: object, options?: ValidatorOptions): Promise<ValidationError[]>;
11 /**
12 * Performs validation of the given object based on validation schema.
13 */
14 validate(schemaName: string, object: object, options?: ValidatorOptions): Promise<ValidationError[]>;
15 /**
16 * Performs validation of the given object based on decorators used in given object class and reject on error.
17 */
18 validateOrReject(object: object, options?: ValidatorOptions): Promise<void>;
19 /**
20 * Performs validation of the given object based on validation schema and reject on error.
21 */
22 validateOrReject(schemaName: string, object: object, options?: ValidatorOptions): Promise<void>;
23 /**
24 * Performs validation of the given object based on decorators used in given object class.
25 * NOTE: This method completely ignores all async validations.
26 */
27 validateSync(object: object, options?: ValidatorOptions): ValidationError[];
28 /**
29 * Performs validation of the given object based on validation schema.
30 */
31 validateSync(schemaName: string, object: object, options?: ValidatorOptions): ValidationError[];
32 /**
33 * Performs validation of the given object based on decorators or validation schema.
34 * Common method for `validateOrReject` and `validate` methods.
35 */
36 private coreValidate;
37}