Desafio: Simple Password Validator

Regras para a senha:


A solução implementada foi:

function SimplePassword(str) {
  // 1. Verifica tamanho
  if (str.length < 7 || str.length > 31) return false;

  // 2. Não pode conter "password" (ignorar maiúscula/minúscula)
  if (str.toLowerCase().includes("password")) return false;

  // 3. Verificações com regex
  const hasUpper = /[A-Z]/.test(str);
  const hasLower = /[a-z]/.test(str);
  const hasNumber = /[0-9]/.test(str);
  const hasSymbol = /[^a-zA-Z0-9]/.test(str);

  return hasUpper && hasLower && hasNumber && hasSymbol;
}


🔍 Explicação da solução

  1. Validação do tamanho:
  2. Checagem da palavra proibida:
  3. Verificações com Regex:
  4. Resultado final: