From 65fcc3119c334b75dd13bcfdebf186afdc580a8f Mon Sep 17 00:00:00 2001 From: Chocobozzz Date: Mon, 15 May 2017 22:22:03 +0200 Subject: First typescript iteration --- server/helpers/custom-validators/users.js | 36 ------------------------------- 1 file changed, 36 deletions(-) delete mode 100644 server/helpers/custom-validators/users.js (limited to 'server/helpers/custom-validators/users.js') 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 @@ -'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 -- cgit v1.2.3