X-Git-Url: https://git.immae.eu/?a=blobdiff_plain;f=server%2Fhelpers%2Fcustom-validators%2Fmisc.ts;h=cf32201c411a6532e6c002c88282b699657ddee7;hb=3b0bd70aa05ab82fa30fe67ed4899d44652c703a;hp=1b7e00431094aef26d0d15369b7f53467e7171ea;hpb=c8861d5dc0436ef4342ce517241e3591fa256a13;p=github%2FChocobozzz%2FPeerTube.git diff --git a/server/helpers/custom-validators/misc.ts b/server/helpers/custom-validators/misc.ts index 1b7e00431..cf32201c4 100644 --- a/server/helpers/custom-validators/misc.ts +++ b/server/helpers/custom-validators/misc.ts @@ -1,7 +1,6 @@ import 'multer' -import * as validator from 'validator' +import validator from 'validator' import { sep } from 'path' -import toBoolean = require('validator/lib/toBoolean') function exists (value: any) { return value !== undefined && value !== null @@ -52,7 +51,7 @@ function toIntOrNull (value: string) { if (v === null || v === undefined) return v if (typeof v === 'number') return v - return validator.toInt(v) + return validator.toInt('' + v) } function toBooleanOrNull (value: any) { @@ -61,7 +60,7 @@ function toBooleanOrNull (value: any) { if (v === null || v === undefined) return v if (typeof v === 'boolean') return v - return toBoolean(v) + return validator.toBoolean('' + v) } function toValueOrNull (value: string) { @@ -95,13 +94,13 @@ function isFileValid ( if (isArray(files)) return optional // Should have a file - const fileArray = files[ field ] + const fileArray = files[field] if (!fileArray || fileArray.length === 0) { return optional } // The file should exist - const file = fileArray[ 0 ] + const file = fileArray[0] if (!file || !file.originalname) return false // Check size