aboutsummaryrefslogtreecommitdiffhomepage
path: root/server/helpers/custom-validators/users.js
diff options
context:
space:
mode:
authorChocobozzz <florian.bigard@gmail.com>2017-05-15 22:22:03 +0200
committerChocobozzz <florian.bigard@gmail.com>2017-05-20 09:57:40 +0200
commit65fcc3119c334b75dd13bcfdebf186afdc580a8f (patch)
tree4f2158c61a9b7c3f47cfa233d01413b946ee53c0 /server/helpers/custom-validators/users.js
parentd5f345ed4cfac4e1fa84dcb4fce1cda4d32f9c73 (diff)
downloadPeerTube-65fcc3119c334b75dd13bcfdebf186afdc580a8f.tar.gz
PeerTube-65fcc3119c334b75dd13bcfdebf186afdc580a8f.tar.zst
PeerTube-65fcc3119c334b75dd13bcfdebf186afdc580a8f.zip
First typescript iteration
Diffstat (limited to 'server/helpers/custom-validators/users.js')
-rw-r--r--server/helpers/custom-validators/users.js36
1 files changed, 0 insertions, 36 deletions
diff --git a/server/helpers/custom-validators/users.js b/server/helpers/custom-validators/users.js
deleted file mode 100644
index 2fc026e98..000000000
--- a/server/helpers/custom-validators/users.js
+++ /dev/null
@@ -1,36 +0,0 @@
1'use strict'
2
3const validator = require('express-validator').validator
4const values = require('lodash/values')
5
6const constants = require('../../initializers/constants')
7const USERS_CONSTRAINTS_FIELDS = constants.CONSTRAINTS_FIELDS.USERS
8
9const usersValidators = {
10 isUserPasswordValid,
11 isUserRoleValid,
12 isUserUsernameValid,
13 isUserDisplayNSFWValid
14}
15
16function isUserPasswordValid (value) {
17 return validator.isLength(value, USERS_CONSTRAINTS_FIELDS.PASSWORD)
18}
19
20function isUserRoleValid (value) {
21 return values(constants.USER_ROLES).indexOf(value) !== -1
22}
23
24function isUserUsernameValid (value) {
25 const max = USERS_CONSTRAINTS_FIELDS.USERNAME.max
26 const min = USERS_CONSTRAINTS_FIELDS.USERNAME.min
27 return validator.matches(value, new RegExp(`^[a-zA-Z0-9._]{${min},${max}}$`))
28}
29
30function isUserDisplayNSFWValid (value) {
31 return validator.isBoolean(value)
32}
33
34// ---------------------------------------------------------------------------
35
36module.exports = usersValidators