修改测试类。
parent
5dbdcc7d10
commit
1d4eadaefe
|
@ -4,9 +4,12 @@ import java.util.Arrays;
|
||||||
import java.util.List;
|
import java.util.List;
|
||||||
import java.util.Objects;
|
import java.util.Objects;
|
||||||
|
|
||||||
|
import org.apache.commons.lang3.StringUtils;
|
||||||
import org.junit.jupiter.api.Test;
|
import org.junit.jupiter.api.Test;
|
||||||
|
|
||||||
import xyz.zhouxy.plusone.commons.constant.PatternConsts;
|
import xyz.zhouxy.plusone.commons.constant.PatternConsts;
|
||||||
|
import xyz.zhouxy.plusone.commons.function.Predicates;
|
||||||
|
import xyz.zhouxy.plusone.commons.util.RegexUtil;
|
||||||
import xyz.zhouxy.plusone.validator.BaseValidator;
|
import xyz.zhouxy.plusone.validator.BaseValidator;
|
||||||
import xyz.zhouxy.plusone.validator.ValidateUtil;
|
import xyz.zhouxy.plusone.validator.ValidateUtil;
|
||||||
|
|
||||||
|
@ -28,9 +31,11 @@ class RegisterCommandValidator extends BaseValidator<RegisterCommand> {
|
||||||
|
|
||||||
private RegisterCommandValidator() {
|
private RegisterCommandValidator() {
|
||||||
ruleForString(RegisterCommand::getUsername)
|
ruleForString(RegisterCommand::getUsername)
|
||||||
.notNull("用户名不能为空")
|
.isTrue(Predicates.<String>of(Objects::nonNull)
|
||||||
.matches(PatternConsts.USERNAME,
|
.and(StringUtils::isNotEmpty)
|
||||||
username -> new IllegalArgumentException(String.format("用户名\"%s\"不符合规范", username)));
|
.and(StringUtils::isNotBlank)
|
||||||
|
.and(username -> RegexUtil.matches(username, PatternConsts.USERNAME)),
|
||||||
|
username -> new IllegalArgumentException(String.format("用户名【%s】不符合规范", username)));
|
||||||
ruleForString(RegisterCommand::getAccount)
|
ruleForString(RegisterCommand::getAccount)
|
||||||
.notNull("请输入邮箱地址或手机号")
|
.notNull("请输入邮箱地址或手机号")
|
||||||
.matchesOne(Arrays.asList(PatternConsts.EMAIL, PatternConsts.MOBILE_PHONE), "请输入邮箱地址或手机号");
|
.matchesOne(Arrays.asList(PatternConsts.EMAIL, PatternConsts.MOBILE_PHONE), "请输入邮箱地址或手机号");
|
||||||
|
|
Loading…
Reference in New Issue