Add data normalization and validation. Add validation error error type.
Add lookup by code method to pis class.
This commit is contained in:
@@ -14,4 +14,11 @@ export class ApiError extends Error {
|
||||
// cast fallback to ensure it satisfies union
|
||||
this.code = errorObj.code || ("SERVER" as ApiErrorCode);
|
||||
}
|
||||
}
|
||||
|
||||
export class ValidationError extends Error {
|
||||
constructor(public field: string, public reason: string) {
|
||||
super(`validation failed for ${field}: ${reason}`);
|
||||
this.name = "VALIDATIONERROR";
|
||||
}
|
||||
}
|
||||
Reference in New Issue
Block a user