aboutsummaryrefslogtreecommitdiffhomepage
path: root/server/helpers/custom-validators/users.js
diff options
context:
space:
mode:
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