From a4101923e699e49ceb9ff36e971c75417fafc9f0 Mon Sep 17 00:00:00 2001 From: Chocobozzz Date: Wed, 9 Jan 2019 15:14:29 +0100 Subject: Implement contact form on server side --- server/helpers/custom-validators/servers.ts | 11 +++++++++++ 1 file changed, 11 insertions(+) (limited to 'server/helpers/custom-validators/servers.ts') 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 } -- cgit v1.2.3