mirror of
https://github.com/tomru/pfadi-bussle.git
synced 2026-03-03 22:47:15 +01:00
26 lines
588 B
TypeScript
26 lines
588 B
TypeScript
interface ValidationErrors {
|
|
[key: string]: { properties: { message: string } }
|
|
}
|
|
|
|
export class ValidationError extends Error {
|
|
private errors: ValidationErrors
|
|
|
|
constructor(errors: ValidationErrors) {
|
|
super()
|
|
|
|
if (Error.captureStackTrace) {
|
|
Error.captureStackTrace(this, ValidationError)
|
|
}
|
|
this.name = this.constructor.name
|
|
this.errors = errors
|
|
}
|
|
|
|
get message() {
|
|
return Object.entries<{ properties: { message: string } }>(this.errors)
|
|
.map(([_key, value]) => {
|
|
return `${value?.properties?.message}`
|
|
})
|
|
.join(',')
|
|
}
|
|
}
|