Add data normalization and validation. Add validation error error type.

Add lookup by code method to pis class.
This commit is contained in:
2026-02-21 19:28:26 +00:00
parent edca2698a7
commit 16bb7d3510
4 changed files with 112 additions and 6 deletions

View File

@@ -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";
}
}