UNPKG

1.04 kBTypeScriptView Raw
1import { AppError, ErrorData } from '@naturalcycles/js-lib';
2import { ValidationErrorItem } from 'joi';
3/**
4 * Example of ValidationErrorItem:
5 *
6 * {
7 * message: '"temperature" must be larger than or equal to 33',
8 * path: [ 'entries', 10, 'temperature' ],
9 * type: 'number.min',
10 * context: { limit: 33, value: 30, key: 'temperature', label: 'temperature' }
11 * }
12 */
13export interface JoiValidationErrorData extends ErrorData {
14 joiValidationErrorItems: ValidationErrorItem[];
15 joiValidationObjectName?: string;
16 joiValidationObjectId?: string;
17 /**
18 * Error "annotation" is stripped in Error.message.
19 * This field contains the "full" annotation.
20 *
21 * This field is non-enumerable, won't be printed or included in JSON by default,
22 * but still accessible programmatically (via `err.data.annotation`) when needed!
23 */
24 annotation?: string;
25}
26export declare class JoiValidationError extends AppError<JoiValidationErrorData> {
27 constructor(message: string, data: JoiValidationErrorData);
28}