Skip to content

Commit

Permalink
v6.5.3
Browse files Browse the repository at this point in the history
  • Loading branch information
839128 committed Jul 7, 2022
1 parent 528059f commit 6b5789c
Showing 1 changed file with 29 additions and 0 deletions.
29 changes: 29 additions & 0 deletions bus-core/src/main/java/org/aoju/bus/core/lang/Validator.java
Original file line number Diff line number Diff line change
Expand Up @@ -1150,4 +1150,33 @@ public static <T extends CharSequence> T validateCarDrivingLicence(T value, Stri
return value;
}

/**
* 验证是否符合密码要求
*
* @param value 值
* @param weak 是否弱密码
* @return 否符合密码要求
*/
public static boolean isPassword(String value, boolean... weak) {
boolean result = false;
for (final boolean element : weak) {
result ^= element;
}
return result ? isMatchRegex(RegEx.PASSWORD_WEAK, value) : isMatchRegex(RegEx.PASSWORD_STRONG, value);
}

/**
* 验证是是否符合密码要求
*
* @param value 值
* @param errorMsg 验证错误的信息
* @param weak 是否弱密码
* @throws ValidateException 验证异常
*/
public static void validatePassword(String value, String errorMsg, boolean... weak) throws ValidateException {
if (false == isPassword(value, weak)) {
throw new ValidateException(errorMsg);
}
}

}

0 comments on commit 6b5789c

Please sign in to comment.