2024-05-26 03:06:28 +00:00
|
|
|
// SPDX-FileCopyrightText: 2024 Mehdi Benadel <https://mehdibenadel.com>
|
|
|
|
//
|
|
|
|
// SPDX-License-Identifier: AGPL-3.0-only
|
|
|
|
|
|
|
|
export enum ValidationErrorType {
|
2024-06-06 09:36:07 +00:00
|
|
|
Missing,
|
2024-05-26 03:06:28 +00:00
|
|
|
WrongType,
|
|
|
|
WrongFormat,
|
|
|
|
NotInRange,
|
2024-06-21 16:18:11 +00:00
|
|
|
Duplicate,
|
|
|
|
TooLong
|
2024-05-26 03:06:28 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
export class ValidationError extends Error {
|
2024-09-09 16:47:21 +00:00
|
|
|
properties: Record<string, ValidationErrorType[]> = {}
|
2024-06-05 16:27:57 +00:00
|
|
|
|
|
|
|
constructor (name: string, message: string | undefined, properties: ValidationError['properties']) {
|
|
|
|
super(message)
|
|
|
|
this.name = name
|
|
|
|
this.properties = properties
|
|
|
|
}
|
2024-05-26 03:06:28 +00:00
|
|
|
}
|