]> git.immae.eu Git - github/Chocobozzz/PeerTube.git/blobdiff - server/helpers/custom-validators/misc.ts
Account/channel descriptions are not required anymore
[github/Chocobozzz/PeerTube.git] / server / helpers / custom-validators / misc.ts
index 8a270b77709502cd8c4b0de4bbd1446f175ba174..275482fa19ca2d2c9bc5c1df5fd54106783cc167 100644 (file)
@@ -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
 }