parent
6723677b23
commit
2768e4eb2b
|
@ -3,7 +3,7 @@ package xyz.zhouxy.plusone.validator;
|
||||||
import java.util.function.Function;
|
import java.util.function.Function;
|
||||||
import java.util.function.Supplier;
|
import java.util.function.Supplier;
|
||||||
|
|
||||||
class BoolValidator<DTO> extends PropertyValidator<DTO, Boolean, BoolValidator<DTO>> {
|
public class BoolValidator<DTO> extends PropertyValidator<DTO, Boolean, BoolValidator<DTO>> {
|
||||||
|
|
||||||
BoolValidator(Function<DTO, Boolean> getter) {
|
BoolValidator(Function<DTO, Boolean> getter) {
|
||||||
super(getter);
|
super(getter);
|
||||||
|
|
|
@ -4,16 +4,12 @@ import java.util.Collection;
|
||||||
import java.util.function.Function;
|
import java.util.function.Function;
|
||||||
import java.util.function.Supplier;
|
import java.util.function.Supplier;
|
||||||
|
|
||||||
class CollectionValidator<DTO, T> extends PropertyValidator<DTO, Collection<T>, CollectionValidator<DTO, T>> {
|
public class CollectionValidator<DTO, T> extends PropertyValidator<DTO, Collection<T>, CollectionValidator<DTO, T>> {
|
||||||
|
|
||||||
CollectionValidator(Function<DTO, Collection<T>> getter) {
|
CollectionValidator(Function<DTO, Collection<T>> getter) {
|
||||||
super(getter);
|
super(getter);
|
||||||
}
|
}
|
||||||
|
|
||||||
// ================================
|
|
||||||
// ====== Collection, String ======
|
|
||||||
// ================================
|
|
||||||
|
|
||||||
// ====== notEmpty =====
|
// ====== notEmpty =====
|
||||||
|
|
||||||
public CollectionValidator<DTO, T> notEmpty(String errMsg) {
|
public CollectionValidator<DTO, T> notEmpty(String errMsg) {
|
||||||
|
|
|
@ -3,7 +3,7 @@ package xyz.zhouxy.plusone.validator;
|
||||||
import java.util.function.Function;
|
import java.util.function.Function;
|
||||||
import java.util.function.Supplier;
|
import java.util.function.Supplier;
|
||||||
|
|
||||||
class DoubleValidator<DTO> extends PropertyValidator<DTO, Double, DoubleValidator<DTO>> {
|
public class DoubleValidator<DTO> extends PropertyValidator<DTO, Double, DoubleValidator<DTO>> {
|
||||||
|
|
||||||
DoubleValidator(Function<DTO, Double> getter) {
|
DoubleValidator(Function<DTO, Double> getter) {
|
||||||
super(getter);
|
super(getter);
|
||||||
|
|
|
@ -3,7 +3,7 @@ package xyz.zhouxy.plusone.validator;
|
||||||
import java.util.function.Function;
|
import java.util.function.Function;
|
||||||
import java.util.function.Supplier;
|
import java.util.function.Supplier;
|
||||||
|
|
||||||
class IntValidator<DTO> extends PropertyValidator<DTO, Integer, IntValidator<DTO>> {
|
public class IntValidator<DTO> extends PropertyValidator<DTO, Integer, IntValidator<DTO>> {
|
||||||
|
|
||||||
IntValidator(Function<DTO, Integer> getter) {
|
IntValidator(Function<DTO, Integer> getter) {
|
||||||
super(getter);
|
super(getter);
|
||||||
|
|
|
@ -2,7 +2,7 @@ package xyz.zhouxy.plusone.validator;
|
||||||
|
|
||||||
import java.util.function.Function;
|
import java.util.function.Function;
|
||||||
|
|
||||||
class ObjectValidator<DTO, T> extends PropertyValidator<DTO, T, ObjectValidator<DTO, T>> {
|
public class ObjectValidator<DTO, T> extends PropertyValidator<DTO, T, ObjectValidator<DTO, T>> {
|
||||||
|
|
||||||
ObjectValidator(Function<DTO, T> getter) {
|
ObjectValidator(Function<DTO, T> getter) {
|
||||||
super(getter);
|
super(getter);
|
||||||
|
|
|
@ -8,7 +8,7 @@ import cn.hutool.core.util.StrUtil;
|
||||||
import xyz.zhouxy.plusone.constant.RegexConsts;
|
import xyz.zhouxy.plusone.constant.RegexConsts;
|
||||||
import xyz.zhouxy.plusone.util.RegexUtil;
|
import xyz.zhouxy.plusone.util.RegexUtil;
|
||||||
|
|
||||||
class StringValidator<DTO> extends PropertyValidator<DTO, String, StringValidator<DTO>> {
|
public class StringValidator<DTO> extends PropertyValidator<DTO, String, StringValidator<DTO>> {
|
||||||
|
|
||||||
StringValidator(Function<DTO, String> getter) {
|
StringValidator(Function<DTO, String> getter) {
|
||||||
super(getter);
|
super(getter);
|
||||||
|
|
|
@ -1,4 +1,4 @@
|
||||||
package xyz.zhouxy.plusone.validator;
|
package xyz.zhouxy.plusone.validator.test;
|
||||||
|
|
||||||
import java.util.Arrays;
|
import java.util.Arrays;
|
||||||
import java.util.List;
|
import java.util.List;
|
||||||
|
@ -7,11 +7,13 @@ import java.util.Objects;
|
||||||
import org.junit.Test;
|
import org.junit.Test;
|
||||||
|
|
||||||
import xyz.zhouxy.plusone.constant.RegexConsts;
|
import xyz.zhouxy.plusone.constant.RegexConsts;
|
||||||
|
import xyz.zhouxy.plusone.validator.BaseValidator;
|
||||||
|
import xyz.zhouxy.plusone.validator.IValidateRequired;
|
||||||
|
|
||||||
public class BaseValidatorTest {
|
public class BaseValidatorTest {
|
||||||
@Test
|
@Test
|
||||||
public void testRuleFor() {
|
public void testRuleFor() {
|
||||||
RegisterCommand registerCommand = new RegisterCommand("me", "luquanlion@outlook.com", "22336", "A1b2C3d4",
|
RegisterCommand registerCommand = new RegisterCommand("zhouxy108", "luquanlion@outlook.com", "22336", "A1b2C3d4",
|
||||||
"A1b2C3d4",
|
"A1b2C3d4",
|
||||||
Arrays.asList(new String[] { "admin", "editor" }));
|
Arrays.asList(new String[] { "admin", "editor" }));
|
||||||
registerCommand.validate();
|
registerCommand.validate();
|
Loading…
Reference in New Issue