UNPKG

2.65 kBTypeScriptView Raw
1/** @module validate */
2import { ValidationResult } from './ValidationResult';
3import { BadRequestException } from '../errors/BadRequestException';
4/**
5 * Errors in schema validation.
6 *
7 * Validation errors are usually generated based in [[ValidationResult]].
8 * If using strict mode, warnings will also raise validation exceptions.
9 *
10 * @see [[BadRequestException]]
11 * @see [[ValidationResult]]
12 */
13export declare class ValidationException extends BadRequestException {
14 private static readonly SerialVersionUid;
15 /**
16 * Creates a new instance of validation exception and assigns its values.
17 *
18 * @param category (optional) a standard error category. Default: Unknown
19 * @param correlation_id (optional) a unique transaction id to trace execution through call chain.
20 * @param results (optional) a list of validation results
21 * @param message (optional) a human-readable description of the error.
22 *
23 * @see [[ValidationResult]]
24 */
25 constructor(correlationId: string, message?: string, results?: ValidationResult[]);
26 /**
27 * Composes human readable error message based on validation results.
28 *
29 * @param results a list of validation results.
30 * @returns a composed error message.
31 *
32 * @see [[ValidationResult]]
33 */
34 static composeMessage(results: ValidationResult[]): string;
35 /**
36 * Creates a new ValidationException based on errors in validation results.
37 * If validation results have no errors, than null is returned.
38 *
39 * @param correlationId (optional) transaction id to trace execution through call chain.
40 * @param results list of validation results that may contain errors
41 * @param strict true to treat warnings as errors.
42 * @returns a newly created ValidationException or null if no errors in found.
43 *
44 * @see [[ValidationResult]]
45 */
46 static fromResults(correlationId: string, results: ValidationResult[], strict: boolean): ValidationException;
47 /**
48 * Throws ValidationException based on errors in validation results.
49 * If validation results have no errors, than no exception is thrown.
50 *
51 * @param correlationId (optional) transaction id to trace execution through call chain.
52 * @param results list of validation results that may contain errors
53 * @param strict true to treat warnings as errors.
54 *
55 * @see [[ValidationResult]]
56 * @see [[ValidationException]]
57 */
58 static throwExceptionIfNeeded(correlationId: string, results: ValidationResult[], strict: boolean): void;
59}