1. 修复 isEmpty 的 bug。
2. 重构校验器。
This commit is contained in:
@@ -15,13 +15,13 @@ import xyz.zhouxy.plusone.validator.DtoValidator;
|
||||
@DtoValidator(LoginByOtpCommand.class)
|
||||
public class LoginByOtpCommandValidator extends BaseValidator<LoginByOtpCommand> {
|
||||
public LoginByOtpCommandValidator() {
|
||||
ruleFor(loginCommand -> {
|
||||
withRule(loginCommand -> {
|
||||
String principal = loginCommand.getPrincipal();
|
||||
return StringUtils.hasText(principal)
|
||||
&&
|
||||
RegexUtil.matchesOr(principal, RegexConsts.EMAIL, RegexConsts.MOBILE_PHONE);
|
||||
}, "输入邮箱地址或手机号");
|
||||
ruleFor(loginCommand -> {
|
||||
withRule(loginCommand -> {
|
||||
String otp = loginCommand.getOtp();
|
||||
return StringUtils.hasText(otp) && Pattern.matches(RegexConsts.CAPTCHA, otp);
|
||||
}, "验证码不符合要求");
|
||||
|
@@ -15,13 +15,13 @@ import xyz.zhouxy.plusone.validator.DtoValidator;
|
||||
@DtoValidator(LoginByPasswordCommand.class)
|
||||
public class LoginByPasswordCommandValidator extends BaseValidator<LoginByPasswordCommand> {
|
||||
public LoginByPasswordCommandValidator() {
|
||||
ruleFor(loginCommand -> {
|
||||
withRule(loginCommand -> {
|
||||
String principal = loginCommand.getPrincipal();
|
||||
return StringUtils.hasText(principal)
|
||||
&&
|
||||
RegexUtil.matchesOr(principal, RegexConsts.USERNAME, RegexConsts.EMAIL, RegexConsts.MOBILE_PHONE, principal);
|
||||
}, "输入用户名、邮箱地址或手机号");
|
||||
ruleFor(loginCommand -> {
|
||||
withRule(loginCommand -> {
|
||||
String password = loginCommand.getPassword();
|
||||
return StringUtils.hasText(password)
|
||||
&&
|
||||
|
Reference in New Issue
Block a user