All files / src/helpers validatePassword.ts

11.11% Statements 1/9
0% Branches 0/2
0% Functions 0/2
12.5% Lines 1/8

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 125x                      
export const validatePassword: (value: string) => boolean = value => {
  if (/\s/.test(value)) {
    return false;
  }
  const hasLowerCase = /(?=.*[a-z])/.test(value);
  const hasUpperCase = /(?=.*[A-Z])/.test(value);
  const hasDigits = /(?=.*\d)/.test(value);
  const hasSpecialCharacter = /(?=.*[!"#$%&'()*+,-./:;<=>?@\[\\\]^_`{|}~])/.test(value);
 
  return [hasLowerCase, hasUpperCase, hasDigits, hasSpecialCharacter].filter(el => el).length > 2;
};