X-Git-Url: https://git.immae.eu/?a=blobdiff_plain;f=server%2Fhelpers%2Fcustom-validators%2Fmisc.ts;h=61c03f0c978fa947e6494452333fa3496aaade56;hb=fb7194043d0486ce0a6a40b2ffbdf32878c33a6f;hp=cf32201c411a6532e6c002c88282b699657ddee7;hpb=a15871560f80e07386c1dabb8370cd2664ecfd1f;p=github%2FChocobozzz%2FPeerTube.git diff --git a/server/helpers/custom-validators/misc.ts b/server/helpers/custom-validators/misc.ts index cf32201c4..61c03f0c9 100644 --- a/server/helpers/custom-validators/misc.ts +++ b/server/helpers/custom-validators/misc.ts @@ -45,6 +45,10 @@ function isBooleanValid (value: any) { return typeof value === 'boolean' || (typeof value === 'string' && validator.isBoolean(value)) } +function isIntOrNull (value: any) { + return value === null || validator.isInt('' + value) +} + function toIntOrNull (value: string) { const v = toValueOrNull(value) @@ -116,6 +120,7 @@ export { isArrayOf, isNotEmptyIntArray, isArray, + isIntOrNull, isIdValid, isSafePath, isUUIDValid,