]>
git.immae.eu Git - github/Chocobozzz/PeerTube.git/blob - server/helpers/custom-validators/users.js
3 const validator
= require('express-validator').validator
4 const values
= require('lodash/values')
6 const constants
= require('../../initializers/constants')
7 const USERS_CONSTRAINTS_FIELDS
= constants
.CONSTRAINTS_FIELDS
.USERS
9 const usersValidators
= {
15 function isUserPasswordValid (value
) {
16 return validator
.isLength(value
, USERS_CONSTRAINTS_FIELDS
.PASSWORD
)
19 function isUserRoleValid (value
) {
20 return values(constants
.USER_ROLES
).indexOf(value
) !== -1
23 function isUserUsernameValid (value
) {
24 const max
= USERS_CONSTRAINTS_FIELDS
.USERNAME
.max
25 const min
= USERS_CONSTRAINTS_FIELDS
.USERNAME
.min
26 return validator
.matches(value
, new RegExp(`^[a-zA-Z0-9._]{${min},${max}}$`))
29 // ---------------------------------------------------------------------------
31 module
.exports
= usersValidators