function checkUsernameValid(req) {
  req.checkBody('username', 'Username is required').notEmpty();
  req.checkBody('username', 'Username must be between 5 and 24 characters.').isLength({
    min: 5,
    max: 24
  });
  req.checkBody('username', 'Username must only contain alphanumeric characters.').matches(/^[0-9a-zA-Z]*$/, "i");
  req.checkBody('username', 'Username may not use profanity.').custom(function(value) {
    return !util.has_profanity(value);
  });
  return req;
}
// For consistency between different forms, validate username through this function.
For consistency between different forms, validate username through this function.
For consistency between different forms validate username through this function .
function checkUsernameValid(req) {
  req.checkBody('username', 'Username is required').notEmpty();
  req.checkBody('username', 'Username must be between 5 and 24 characters.').isLength({
    min: 5,
    max: 24
  });
  req.checkBody('username', 'Username must only contain alphanumeric characters.').matches(/^[0-9a-zA-Z]*$/, "i");
  req.checkBody('username', 'Username may not use profanity.').custom(function(value) {
    return !util.has_profanity(value);
  });
  return req;
}
function checkUsernameValid ( req ) { req . checkBody ( 'username' , 'Username is required' ) . notEmpty ( ) ; req . checkBody ( 'username' , 'Username must be between 5 and 24 characters.' ) . isLength ( { min : 5 , max : 24 } ) ; req . checkBody ( 'username' , 'Username must only contain alphanumeric characters.' ) . matches ( / ^[0-9a-zA-Z]*$ / , "i" ) ; req . checkBody ( 'username' , 'Username may not use profanity.' ) . custom ( function ( value ) { return ! util . has_profanity ( value ) ; } ) ; return req ; }
For consistency between different forms, validate username through this function.
For consistency between different forms validate username through this function .