]> git.immae.eu Git - github/Chocobozzz/PeerTube.git/blobdiff - server/helpers/custom-validators/misc.ts
Update iso639 translations for french and deutch
[github/Chocobozzz/PeerTube.git] / server / helpers / custom-validators / misc.ts
index 8a270b77709502cd8c4b0de4bbd1446f175ba174..254b4db6ccba92b7d0f43dfacc1e5a6956e44b4f 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 toValueOrNull (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,
+  toValueOrNull,
   isBooleanValid,
+  toIntOrNull,
   isFileValid
 }