summary refs log tree commit diff
path: root/src/util/util/FieldError.ts
diff options
context:
space:
mode:
Diffstat (limited to 'src/util/util/FieldError.ts')
-rw-r--r--src/util/util/FieldError.ts23
1 files changed, 23 insertions, 0 deletions
diff --git a/src/util/util/FieldError.ts b/src/util/util/FieldError.ts
new file mode 100644
index 00000000..49968e1a
--- /dev/null
+++ b/src/util/util/FieldError.ts
@@ -0,0 +1,23 @@
+export function FieldErrors(fields: Record<string, { code?: string; message: string }>) {
+	return new FieldError(
+		50035,
+		"Invalid Form Body",
+		fields.map(({ message, code }) => ({
+			_errors: [
+				{
+					message,
+					code: code || "BASE_TYPE_INVALID",
+				},
+			],
+		}))
+	);
+}
+
+// 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
+// Ensure you use the proper content type (image/jpeg, image/png, image/gif) that matches the image data being provided.
+
+export class FieldError extends Error {
+	constructor(public code: string | number, public message: string, public errors?: any) {
+		super(message);
+	}
+}