summary refs log tree commit diff
path: root/api/src/util/FieldError.ts
diff options
context:
space:
mode:
authorFlam3rboy <34555296+Flam3rboy@users.noreply.github.com>2021-09-24 10:43:43 +0200
committerFlam3rboy <34555296+Flam3rboy@users.noreply.github.com>2021-09-24 10:43:43 +0200
commit7d343458ab868ede0cf468e8891333a170fdd24e (patch)
treead9e5464d24dc106734a1c60cf4f299e8d0e8473 /api/src/util/FieldError.ts
parent:sparkles: added User flags (diff)
parent:art: remove start from setup script (diff)
downloadserver-7d343458ab868ede0cf468e8891333a170fdd24e.tar.xz
Merge branch 'master' of https://github.com/fosscord/fosscord-server
Diffstat (limited to 'api/src/util/FieldError.ts')
-rw-r--r--api/src/util/FieldError.ts25
1 files changed, 25 insertions, 0 deletions
diff --git a/api/src/util/FieldError.ts b/api/src/util/FieldError.ts
new file mode 100644

index 00000000..0b3f93d2 --- /dev/null +++ b/api/src/util/FieldError.ts
@@ -0,0 +1,25 @@ +import "missing-native-js-functions"; + +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); + } +}