started working on templates and api
This commit is contained in:
@@ -62,4 +62,26 @@ public class Util {
|
||||
public static boolean isEmail(String email) {
|
||||
return email.matches(EMAIL_PATTERN);
|
||||
}
|
||||
|
||||
public static boolean simplePassword(String pass) {
|
||||
if (pass.length() < 6) return true;
|
||||
if (pass.length() < 8){
|
||||
for (int i=0; i<pass.length();i++){
|
||||
if (!Character.isLetterOrDigit(pass.charAt(i))) return false; // password contains special character
|
||||
}
|
||||
}
|
||||
if (pass.length() < 10){
|
||||
var digit = false;
|
||||
var letter = false;
|
||||
for (int i=0; i<pass.length();i++){
|
||||
char c = pass.charAt(i);
|
||||
if (!Character.isLetterOrDigit(c)) return false; // password contains special character
|
||||
digit |= Character.isDigit(c);
|
||||
letter |= Character.isLetter(c);
|
||||
if (letter && digit) return false; // password contains letters and digits
|
||||
}
|
||||
return true;
|
||||
}
|
||||
return false;
|
||||
}
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user