summary refs log tree commit diff
diff options
context:
space:
mode:
authorCyberL1 <cyber.hf18@gmail.com>2026-01-14 16:05:09 +0100
committerCyberL1 <cyber.hf18@gmail.com>2026-01-14 16:05:09 +0100
commite274ae107dbb47a4354fc143b173080281b6d7c9 (patch)
tree26b816198cae7f0dc2183f7ecd8e14cd79518c49
parentGateway close logging for 4002 (diff)
downloadserver-ts-e274ae107dbb47a4354fc143b173080281b6d7c9.tar.xz
fix: `FieldErrors` function returned array instead of an object
-rw-r--r--src/util/util/FieldError.ts15
1 files changed, 8 insertions, 7 deletions
diff --git a/src/util/util/FieldError.ts b/src/util/util/FieldError.ts

index 8f93b2b6..76b34b82 100644 --- a/src/util/util/FieldError.ts +++ b/src/util/util/FieldError.ts
@@ -29,19 +29,20 @@ export type ErrorContent = { code: string; message: string }; export type ObjectErrorContent = { _errors: ErrorContent[] }; export function FieldErrors(fields: Record<string, { code?: string; message: string }>, errors?: ErrorObject[]) { - return new FieldError( - 50035, - "Invalid Form Body", - Object.values(fields).map(({ message, code }) => ({ + const errorsObject = {} as Record<string, ObjectErrorContent>; + + Object.entries(fields).map(([key, { message, code }]) => { + errorsObject[key] = { _errors: [ { message, code: code || "BASE_TYPE_INVALID", }, ], - })), - errors, - ); + }; + }); + + return new FieldError(50035, "Invalid Form Body", errorsObject, 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