blow-validate
Version:
Validation for Blow entities.
42 lines (33 loc) • 828 B
text/typescript
;
export class ValidationError {
protected _property: string;
protected _type: string;
protected _message: string;
constructor(errorRaw: {property?: string, type: string, message: string}) {
this._property = errorRaw.property;
this._type = errorRaw.type;
this._message = errorRaw.message.replace(/"/g, '\'');
}
get property(): string {
return this._property;
}
get type(): string {
return this._type;
}
get message(): string {
return this._message;
}
toJSON() {
return {
property: this._property,
type: this._type,
message: this._message
};
}
inspect() {
return this.toJSON();
}
static create(errorRaw: {property?: string, type: string, message: string}): ValidationError {
return new ValidationError(errorRaw);
}
}