From 30cd803978a945e038d9b6270b88154cd1d8eaa5 Mon Sep 17 00:00:00 2001 From: MathMan05 Date: Tue, 23 Dec 2025 16:34:00 -0600 Subject: [PATCH] feild error fixes --- src/util/util/FieldError.ts | 16 ++++++++-------- 1 file changed, 8 insertions(+), 8 deletions(-) diff --git a/src/util/util/FieldError.ts b/src/util/util/FieldError.ts index 8f93b2b6e..eb91a0ecb 100644 --- a/src/util/util/FieldError.ts +++ b/src/util/util/FieldError.ts @@ -29,19 +29,19 @@ export type ErrorContent = { code: string; message: string }; export type ObjectErrorContent = { _errors: ErrorContent[] }; export function FieldErrors(fields: Record, errors?: ErrorObject[]) { - return new FieldError( - 50035, - "Invalid Form Body", - Object.values(fields).map(({ message, code }) => ({ + const errorObj: ErrorList = {}; + for (const [key, { message, code }] of Object.entries(fields)) { + errorObj[key] = { _errors: [ { message, code: code || "BASE_TYPE_INVALID", }, ], - })), - errors, - ); + }; + } + + return new FieldError(50035, "Invalid Form Body", errorObj, errors); } // TODO: implement Image data type: Data URI scheme that supports JPG, GIF, and PNG formats. An example Data URI format is: data:image/jpeg;base64,BASE64_ENCODED_JPEG_IMAGE_DATA @@ -51,7 +51,7 @@ export class FieldError extends Error { constructor( public code: string | number, public message: string, - public errors?: object, // TODO: I don't like this typing. + public errors?: ErrorList, public _ajvErrors?: ErrorObject[], ) { super(message);