You can not select more than 25 topics
Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.
21 lines
697 B
21 lines
697 B
package com.mathlearning.util;
|
|
|
|
public class PasswordValidator {
|
|
public static boolean isValid(String password) {
|
|
if (password == null || password.length() < 6 || password.length() > 10) {
|
|
return false;
|
|
}
|
|
|
|
boolean hasUpperCase = false;
|
|
boolean hasLowerCase = false;
|
|
boolean hasDigit = false;
|
|
|
|
for (char c : password.toCharArray()) {
|
|
if (Character.isUpperCase(c)) hasUpperCase = true;
|
|
if (Character.isLowerCase(c)) hasLowerCase = true;
|
|
if (Character.isDigit(c)) hasDigit = true;
|
|
}
|
|
|
|
return hasUpperCase && hasLowerCase && hasDigit;
|
|
}
|
|
} |