All files / utils validateNickname.js

100% Statements 3/3
100% Branches 2/2
100% Functions 1/1
100% Lines 3/3

Press n or j to go to the next uncovered block, b, p or k for the previous block.

1 2 3 4 5 6 7 8 9 10 11 12 13 14            2x     18x     2x  
/**
 * Nicknames are unique, public handles (e.g. "@chris_74") used to invite users
 * to a flow without exposing their email address.
 *
 * 3-20 characters, lowercase letters/digits/underscores only, must start with a letter.
 */
const NICKNAME_REGEX = /^[a-z][a-z0-9_]{2,19}$/
 
function isValidNickname(nickname) {
  return typeof nickname === 'string' && NICKNAME_REGEX.test(nickname)
}
 
module.exports = { isValidNickname, NICKNAME_REGEX }