mirror of
https://github.com/Chocobozzz/PeerTube.git
synced 2025-10-03 17:59:37 +02:00
First typescript iteration
This commit is contained in:
parent
d5f345ed4c
commit
65fcc3119c
113 changed files with 1961 additions and 1784 deletions
|
@ -1,36 +0,0 @@
|
|||
'use strict'
|
||||
|
||||
const validator = require('express-validator').validator
|
||||
const values = require('lodash/values')
|
||||
|
||||
const constants = require('../../initializers/constants')
|
||||
const USERS_CONSTRAINTS_FIELDS = constants.CONSTRAINTS_FIELDS.USERS
|
||||
|
||||
const usersValidators = {
|
||||
isUserPasswordValid,
|
||||
isUserRoleValid,
|
||||
isUserUsernameValid,
|
||||
isUserDisplayNSFWValid
|
||||
}
|
||||
|
||||
function isUserPasswordValid (value) {
|
||||
return validator.isLength(value, USERS_CONSTRAINTS_FIELDS.PASSWORD)
|
||||
}
|
||||
|
||||
function isUserRoleValid (value) {
|
||||
return values(constants.USER_ROLES).indexOf(value) !== -1
|
||||
}
|
||||
|
||||
function isUserUsernameValid (value) {
|
||||
const max = USERS_CONSTRAINTS_FIELDS.USERNAME.max
|
||||
const min = USERS_CONSTRAINTS_FIELDS.USERNAME.min
|
||||
return validator.matches(value, new RegExp(`^[a-zA-Z0-9._]{${min},${max}}$`))
|
||||
}
|
||||
|
||||
function isUserDisplayNSFWValid (value) {
|
||||
return validator.isBoolean(value)
|
||||
}
|
||||
|
||||
// ---------------------------------------------------------------------------
|
||||
|
||||
module.exports = usersValidators
|
Loading…
Add table
Add a link
Reference in a new issue