Reputation: 1
In Javascript, how to add method to a password class that checks for validity.
how to add method to a password class that checks for validity in javascript.
Upvotes: 0
Views: 18
Reputation: 543
I am not completely sure about the requirement, but perhaps below would help
class Password{
constructor(passString){
this.passString = passString;
}
checkLength = () => {
return this.passString.lenght>8;
}
checkSpecialChars = () => { // TODO Need to implement
return true;
}
checkUpperChar = () => { // TODO Need to implement
return true;
}
checkLowerChar = () => { // TODO Need to implement
return true;
}
isValid = () => {
return this.checkLength() && this.checkSpecialChars() && this.checkLowerChar() && this.checkUpperChar();
}
}
let pass = new Password("ANUBHAV");
console.log(pass.isValid());
Upvotes: 0