diff options
Diffstat (limited to 'server/helpers/custom-validators/users.js')
-rw-r--r-- | server/helpers/custom-validators/users.js | 36 |
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 | |||
3 | const validator = require('express-validator').validator | ||
4 | const values = require('lodash/values') | ||
5 | |||
6 | const constants = require('../../initializers/constants') | ||
7 | const USERS_CONSTRAINTS_FIELDS = constants.CONSTRAINTS_FIELDS.USERS | ||
8 | |||
9 | const usersValidators = { | ||
10 | isUserPasswordValid, | ||
11 | isUserRoleValid, | ||
12 | isUserUsernameValid, | ||
13 | isUserDisplayNSFWValid | ||
14 | } | ||
15 | |||
16 | function isUserPasswordValid (value) { | ||
17 | return validator.isLength(value, USERS_CONSTRAINTS_FIELDS.PASSWORD) | ||
18 | } | ||
19 | |||
20 | function isUserRoleValid (value) { | ||
21 | return values(constants.USER_ROLES).indexOf(value) !== -1 | ||
22 | } | ||
23 | |||
24 | function 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 | |||
30 | function isUserDisplayNSFWValid (value) { | ||
31 | return validator.isBoolean(value) | ||
32 | } | ||
33 | |||
34 | // --------------------------------------------------------------------------- | ||
35 | |||
36 | module.exports = usersValidators | ||