优化代码。
This commit is contained in:
@@ -32,10 +32,10 @@ class LoginCommandValidator extends BaseValidator2<LoginCommand> {
|
|||||||
public static final LoginCommandValidator INSTANCE = new LoginCommandValidator();
|
public static final LoginCommandValidator INSTANCE = new LoginCommandValidator();
|
||||||
|
|
||||||
private LoginCommandValidator() {
|
private LoginCommandValidator() {
|
||||||
ruleFor(loginCommand -> loginCommand.getAccount())
|
ruleFor(LoginCommand::getAccount)
|
||||||
.notNull("邮箱地址不能为空")
|
.notNull("邮箱地址不能为空")
|
||||||
.matchesOr(new String[] { RegexConsts.EMAIL, RegexConsts.MOBILE_PHONE }, value -> new RuntimeException('"' + value + "\" 不是邮箱地址或手机号"));
|
.matchesOr(new String[] { RegexConsts.EMAIL, RegexConsts.MOBILE_PHONE }, value -> new RuntimeException('"' + value + "\" 不是邮箱地址或手机号"));
|
||||||
ruleFor(loginCommand -> loginCommand.getPwd())
|
ruleFor(LoginCommand::getPwd)
|
||||||
.notNull("密码不能为空")
|
.notNull("密码不能为空")
|
||||||
.notEmpty("密码不能为空")
|
.notEmpty("密码不能为空")
|
||||||
.matches(RegexConsts.PASSWORD, "密码格式错误");
|
.matches(RegexConsts.PASSWORD, "密码格式错误");
|
||||||
|
Reference in New Issue
Block a user