All files / src/utils validationErr.js

16.66% Statements 1/6
0% Branches 0/3
0% Functions 0/1
16.66% Lines 1/6

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 15                          1x  
function errorValidator (reply, errorMessage, action, email, password) {
  const nonce = { scriptN: reply.cspNonce.script, styleN: reply.cspNonce.style }
 
  switch (errorMessage) {
    case 'body/email must match pattern "^\\S+@\\S+\\.\\S+$"':
      return reply.code(400).view('session.hbs', { error: 'please enter a valid email', button: action, action: '/' + action, email, password, ...nonce })
    case 'body/password must NOT have fewer than 5 characters':
      return reply.code(400).view('session.hbs', { error: 'password is to short', button: action, action: '/' + action, email, password, ...nonce })
    case 'body/url must match pattern "^(ftp|http|https):[^ "]+$"':
      return reply.code(409).view('error.hbs', { message: '400', subtitle: 'Please enter a valid url', ...nonce })
  }
}
 
module.exports = errorValidator