X-Git-Url: https://git.immae.eu/?a=blobdiff_plain;f=server%2Fhelpers%2Fcustom-validators%2Fmisc.ts;h=3a3deab0c8f7b152ac56d08348d003b84286c247;hb=1eddc9a74f9a80fa5d0cb25fceb3fc47a1a3c14a;hp=76647fea2be8264c424d887dd6252afc2ebda3ba;hpb=b718fd22374d64534bcfe69932cf562894abed6a;p=github%2FChocobozzz%2FPeerTube.git diff --git a/server/helpers/custom-validators/misc.ts b/server/helpers/custom-validators/misc.ts index 76647fea2..3a3deab0c 100644 --- a/server/helpers/custom-validators/misc.ts +++ b/server/helpers/custom-validators/misc.ts @@ -49,12 +49,19 @@ function toValueOrNull (value: string) { return value } -function toArray (value: string) { +function toArray (value: any) { if (value && isArray(value) === false) return [ value ] return value } +function toIntArray (value: any) { + if (!value) return [] + if (isArray(value) === false) return [ validator.toInt(value) ] + + return value.map(v => validator.toInt(v)) +} + function isFileValid ( files: { [ fieldname: string ]: Express.Multer.File[] } | Express.Multer.File[], mimeTypeRegex: string, @@ -97,5 +104,6 @@ export { isBooleanValid, toIntOrNull, toArray, + toIntArray, isFileValid }