From 360329cc029c062bfb145c90f7bf1c007c39af81 Mon Sep 17 00:00:00 2001 From: Chocobozzz Date: Wed, 9 May 2018 11:23:14 +0200 Subject: Account/channel descriptions are not required anymore --- server/helpers/custom-validators/misc.ts | 16 +++++++++++++++- 1 file changed, 15 insertions(+), 1 deletion(-) (limited to 'server/helpers/custom-validators') diff --git a/server/helpers/custom-validators/misc.ts b/server/helpers/custom-validators/misc.ts index 8a270b777..275482fa1 100644 --- a/server/helpers/custom-validators/misc.ts +++ b/server/helpers/custom-validators/misc.ts @@ -25,10 +25,22 @@ function isIdOrUUIDValid (value: string) { return isIdValid(value) || isUUIDValid(value) } -function isBooleanValid (value: string) { +function isBooleanValid (value: any) { return typeof value === 'boolean' || (typeof value === 'string' && validator.isBoolean(value)) } +function toIntOrNull (value: string) { + if (value === 'null') return null + + return validator.toInt(value) +} + +function toStringOrNull (value: string) { + if (value === 'null') return null + + return value +} + function isFileValid ( files: { [ fieldname: string ]: Express.Multer.File[] } | Express.Multer.File[], mimeTypeRegex: string, @@ -61,6 +73,8 @@ export { isUUIDValid, isIdOrUUIDValid, isDateValid, + toStringOrNull, isBooleanValid, + toIntOrNull, isFileValid } -- cgit v1.2.3