@naturalcycles/nodejs-lib
Version:
Standard library for Node.js
29 lines (28 loc) • 1.04 kB
TypeScript
import { AppError, ErrorData } from '@naturalcycles/js-lib';
import { ValidationErrorItem } from 'joi';
/**
* Example of ValidationErrorItem:
*
* {
* message: '"temperature" must be larger than or equal to 33',
* path: [ 'entries', 10, 'temperature' ],
* type: 'number.min',
* context: { limit: 33, value: 30, key: 'temperature', label: 'temperature' }
* }
*/
export interface JoiValidationErrorData extends ErrorData {
joiValidationErrorItems: ValidationErrorItem[];
joiValidationObjectName?: string;
joiValidationObjectId?: string;
/**
* Error "annotation" is stripped in Error.message.
* This field contains the "full" annotation.
*
* This field is non-enumerable, won't be printed or included in JSON by default,
* but still accessible programmatically (via `err.data.annotation`) when needed!
*/
annotation?: string;
}
export declare class JoiValidationError extends AppError<JoiValidationErrorData> {
constructor(message: string, data: JoiValidationErrorData);
}