validateUserNameExists()

This commit is contained in:
Bryan Ashby 2016-07-25 01:01:14 -06:00
parent 820e150708
commit 87c6746676
1 changed files with 13 additions and 0 deletions

View File

@ -4,6 +4,7 @@ var Config = require('./config.js').config;
exports.validateNonEmpty = validateNonEmpty; exports.validateNonEmpty = validateNonEmpty;
exports.validateMessageSubject = validateMessageSubject; exports.validateMessageSubject = validateMessageSubject;
exports.validateUserNameAvail = validateUserNameAvail; exports.validateUserNameAvail = validateUserNameAvail;
exports.validateUserNameExists = validateUserNameExists;
exports.validateEmailAvail = validateEmailAvail; exports.validateEmailAvail = validateEmailAvail;
exports.validateBirthdate = validateBirthdate; exports.validateBirthdate = validateBirthdate;
exports.validatePasswordSpec = validatePasswordSpec; exports.validatePasswordSpec = validatePasswordSpec;
@ -42,6 +43,18 @@ function validateUserNameAvail(data, cb) {
} }
} }
function validateUserNameExists(data, cb) {
const invalidUserNameError = new Error('Invalid username');
if(0 === data.length) {
return cb(invalidUserNameError);
}
user.getUserIdAndName(data, (err) => {
return cb(err ? invalidUserNameError : null);
});
}
function validateEmailAvail(data, cb) { function validateEmailAvail(data, cb) {
// //
// This particular method allows empty data - e.g. no email entered // This particular method allows empty data - e.g. no email entered