password-check

Try in Playground
js-rulesUnknownInformational

0

No tags

No CWE or CVE

Ast Rule: try block


password-check

How to write a rule
function visit() {
  let password = 'mypassword';

  if (password.length < 8) {
    throw new Error('The password must be at least 8 characters long.');
  }
}

test-1

Expected test result: no error

let testPassword = 'mypass';

function testPasswordLength() {
  if (testPassword.length < 8) {
    try {
      throw new Error('The password must be at least 8 characters long.');
      return true;
    } catch(err) {
      return false;
    }
  }
}

let result = testPasswordLength();

if (result) {
  console.log("Test Passed");
} else {
  console.log("Test Failed");
}
Add comment

Log in to add a comment


    Be the first one to leave a comment!

Codiga Logo
Codiga Hub
  • Rulesets
  • Playground
  • Snippets
  • Cookbooks
soc-2 icon

We are SOC-2 Compliance Certified

G2 high performer medal

Codiga – All rights reserved 2022.