All files / src/utils password.ts

100% Statements 10/10
100% Branches 13/13
100% Functions 1/1
100% Lines 10/10

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 16 171x 16x   16x     12x 12x 12x 12x 12x     12x   12x  
export function isStrong(pw: string) {
  if (/\s/.test(pw)) return false
  // todo 8 はマジックナンバーなので何処かに定数化したい
  if ([...pw].length < 8) return false
  // if ([...pw].length < 6) return false
 
  let classes = 0
  if (/[A-Z]/.test(pw)) classes++
  if (/[a-z]/.test(pw)) classes++
  if (/[0-9]/.test(pw)) classes++
  if (/[^A-Za-z0-9]/.test(pw)) classes++
 
  // todo 3 はマジックナンバーなので何処かに定数化したい
  return classes >= 3
  // return classes >= 2
}