aboutsummaryrefslogtreecommitdiffhomepage
path: root/server/helpers/custom-validators/servers.ts
diff options
context:
space:
mode:
authorChocobozzz <me@florianbigard.com>2019-01-09 15:14:29 +0100
committerChocobozzz <me@florianbigard.com>2019-01-10 11:32:37 +0100
commita4101923e699e49ceb9ff36e971c75417fafc9f0 (patch)
treec098a87ac5a85e1bc7454facbb59ecbd6c7dac82 /server/helpers/custom-validators/servers.ts
parent8d00889b6038c38d9c86cbeca88a9f3c23962c48 (diff)
downloadPeerTube-a4101923e699e49ceb9ff36e971c75417fafc9f0.tar.gz
PeerTube-a4101923e699e49ceb9ff36e971c75417fafc9f0.tar.zst
PeerTube-a4101923e699e49ceb9ff36e971c75417fafc9f0.zip
Implement contact form on server side
Diffstat (limited to 'server/helpers/custom-validators/servers.ts')
-rw-r--r--server/helpers/custom-validators/servers.ts11
1 files changed, 11 insertions, 0 deletions
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'
3 3
4import { isArray, exists } from './misc' 4import { isArray, exists } from './misc'
5import { isTestInstance } from '../core-utils' 5import { isTestInstance } from '../core-utils'
6import { CONSTRAINTS_FIELDS } from '../../initializers'
6 7
7function isHostValid (host: string) { 8function isHostValid (host: string) {
8 const isURLOptions = { 9 const isURLOptions = {
@@ -26,9 +27,19 @@ function isEachUniqueHostValid (hosts: string[]) {
26 }) 27 })
27} 28}
28 29
30function isValidContactBody (value: any) {
31 return exists(value) && validator.isLength(value, CONSTRAINTS_FIELDS.CONTACT_FORM.BODY)
32}
33
34function isValidContactFromName (value: any) {
35 return exists(value) && validator.isLength(value, CONSTRAINTS_FIELDS.CONTACT_FORM.FROM_NAME)
36}
37
29// --------------------------------------------------------------------------- 38// ---------------------------------------------------------------------------
30 39
31export { 40export {
41 isValidContactBody,
42 isValidContactFromName,
32 isEachUniqueHostValid, 43 isEachUniqueHostValid,
33 isHostValid 44 isHostValid
34} 45}