X-Git-Url: https://git.immae.eu/?a=blobdiff_plain;f=server%2Fhelpers%2Fcustom-validators%2Fservers.ts;h=18c80ec8fcd587f7ee6083c2cf9a53d66962a00c;hb=28f3d1b36a70426795240c9370e47b6c4ba847f8;hp=d5021bf38dbf5b8f553af001b87e5fe06a59128e;hpb=608624252466acf9f1d9ee1c1170bd4fe4d18d18;p=github%2FChocobozzz%2FPeerTube.git diff --git a/server/helpers/custom-validators/servers.ts b/server/helpers/custom-validators/servers.ts index d5021bf38..18c80ec8f 100644 --- a/server/helpers/custom-validators/servers.ts +++ b/server/helpers/custom-validators/servers.ts @@ -3,6 +3,7 @@ import 'express-validator' import { isArray, exists } from './misc' import { isTestInstance } from '../core-utils' +import { CONSTRAINTS_FIELDS } from '../../initializers' function isHostValid (host: string) { const isURLOptions = { @@ -26,9 +27,19 @@ function isEachUniqueHostValid (hosts: string[]) { }) } +function isValidContactBody (value: any) { + return exists(value) && validator.isLength(value, CONSTRAINTS_FIELDS.CONTACT_FORM.BODY) +} + +function isValidContactFromName (value: any) { + return exists(value) && validator.isLength(value, CONSTRAINTS_FIELDS.CONTACT_FORM.FROM_NAME) +} + // --------------------------------------------------------------------------- export { + isValidContactBody, + isValidContactFromName, isEachUniqueHostValid, isHostValid }