Compare commits
1 Commits
ae970cb393
...
245c2e962c
Author | SHA1 | Date | |
---|---|---|---|
245c2e962c |
@@ -16,7 +16,7 @@
|
|||||||
<url>http://zhouxy.xyz</url>
|
<url>http://zhouxy.xyz</url>
|
||||||
|
|
||||||
<description>
|
<description>
|
||||||
Plusone Validator 是一个参数校验框架,可针对 DTO 创建对应的校验器,并复用该校验器实例,对 DTO 进行校验。
|
Plusone Validator 是一个校验库,用于构建校验规则对对象(尤其是入参)进行校验。API 参考自 .NET 的 FluentValidation。
|
||||||
</description>
|
</description>
|
||||||
|
|
||||||
<properties>
|
<properties>
|
||||||
|
@@ -31,8 +31,7 @@ public class DoublePropertyValidator<T>
|
|||||||
// ================================
|
// ================================
|
||||||
|
|
||||||
public DoublePropertyValidator<T> gt(double min) {
|
public DoublePropertyValidator<T> gt(double min) {
|
||||||
return gt(min, () -> new IllegalArgumentException(
|
return gt(min, String.format("The input must be greater than '%s'.", min));
|
||||||
String.format("The input must be greater than '%s'.", min)));
|
|
||||||
}
|
}
|
||||||
|
|
||||||
public DoublePropertyValidator<T> gt(double min, String errMsg) {
|
public DoublePropertyValidator<T> gt(double min, String errMsg) {
|
||||||
@@ -59,8 +58,7 @@ public class DoublePropertyValidator<T>
|
|||||||
// ================================
|
// ================================
|
||||||
|
|
||||||
public DoublePropertyValidator<T> ge(double min) {
|
public DoublePropertyValidator<T> ge(double min) {
|
||||||
return ge(min, () -> new IllegalArgumentException(
|
return ge(min, String.format("The input must be greater than or equal to '%s'.", min));
|
||||||
String.format("The input must be greater than or equal to '%s'.", min)));
|
|
||||||
}
|
}
|
||||||
|
|
||||||
public DoublePropertyValidator<T> ge(double min, String errMsg) {
|
public DoublePropertyValidator<T> ge(double min, String errMsg) {
|
||||||
@@ -87,8 +85,7 @@ public class DoublePropertyValidator<T>
|
|||||||
// ================================
|
// ================================
|
||||||
|
|
||||||
public DoublePropertyValidator<T> lt(double max) {
|
public DoublePropertyValidator<T> lt(double max) {
|
||||||
return lt(max, () -> new IllegalArgumentException(
|
return lt(max, String.format("The input must be less than '%s'.", max));
|
||||||
String.format("The input must be less than '%s'.", max)));
|
|
||||||
}
|
}
|
||||||
|
|
||||||
public DoublePropertyValidator<T> lt(double max, String errMsg) {
|
public DoublePropertyValidator<T> lt(double max, String errMsg) {
|
||||||
@@ -115,8 +112,7 @@ public class DoublePropertyValidator<T>
|
|||||||
// ================================
|
// ================================
|
||||||
|
|
||||||
public DoublePropertyValidator<T> le(double max) {
|
public DoublePropertyValidator<T> le(double max) {
|
||||||
return le(max, () -> new IllegalArgumentException(
|
return le(max, String.format("The input must be less than or equal to '%s'.", max));
|
||||||
String.format("The input must be less than or equal to '%s'.", max)));
|
|
||||||
}
|
}
|
||||||
|
|
||||||
public DoublePropertyValidator<T> le(double max, String errMsg) {
|
public DoublePropertyValidator<T> le(double max, String errMsg) {
|
||||||
|
@@ -31,8 +31,7 @@ public class IntPropertyValidator<T>
|
|||||||
// ================================
|
// ================================
|
||||||
|
|
||||||
public IntPropertyValidator<T> gt(int min) {
|
public IntPropertyValidator<T> gt(int min) {
|
||||||
return gt(min, () -> new IllegalArgumentException(
|
return gt(min, String.format("The input must be greater than '%d'.", min));
|
||||||
String.format("The input must be greater than '%d'.", min)));
|
|
||||||
}
|
}
|
||||||
|
|
||||||
public IntPropertyValidator<T> gt(int min, String errMsg) {
|
public IntPropertyValidator<T> gt(int min, String errMsg) {
|
||||||
@@ -59,8 +58,7 @@ public class IntPropertyValidator<T>
|
|||||||
// ================================
|
// ================================
|
||||||
|
|
||||||
public IntPropertyValidator<T> ge(int min) {
|
public IntPropertyValidator<T> ge(int min) {
|
||||||
return ge(min, () -> new IllegalArgumentException(
|
return ge(min, String.format("The input must be greater than or equal to '%d'.", min));
|
||||||
String.format("The input must be greater than or equal to '%d'.", min)));
|
|
||||||
}
|
}
|
||||||
|
|
||||||
public IntPropertyValidator<T> ge(int min, String errMsg) {
|
public IntPropertyValidator<T> ge(int min, String errMsg) {
|
||||||
@@ -87,8 +85,7 @@ public class IntPropertyValidator<T>
|
|||||||
// ================================
|
// ================================
|
||||||
|
|
||||||
public IntPropertyValidator<T> lt(int max) {
|
public IntPropertyValidator<T> lt(int max) {
|
||||||
return lt(max, () -> new IllegalArgumentException(
|
return lt(max, String.format("The input must be less than '%d'.", max));
|
||||||
String.format("The input must be less than '%d'.", max)));
|
|
||||||
}
|
}
|
||||||
|
|
||||||
public IntPropertyValidator<T> lt(int max, String errMsg) {
|
public IntPropertyValidator<T> lt(int max, String errMsg) {
|
||||||
@@ -115,8 +112,7 @@ public class IntPropertyValidator<T>
|
|||||||
// ================================
|
// ================================
|
||||||
|
|
||||||
public IntPropertyValidator<T> le(int max) {
|
public IntPropertyValidator<T> le(int max) {
|
||||||
return le(max, () -> new IllegalArgumentException(
|
return le(max, String.format("The input must be less than or equal to '%d'.", max));
|
||||||
String.format("The input must be less than or equal to '%d'.", max)));
|
|
||||||
}
|
}
|
||||||
|
|
||||||
public IntPropertyValidator<T> le(int max, String errMsg) {
|
public IntPropertyValidator<T> le(int max, String errMsg) {
|
||||||
|
@@ -31,8 +31,7 @@ public class LongPropertyValidator<T>
|
|||||||
// ================================
|
// ================================
|
||||||
|
|
||||||
public LongPropertyValidator<T> gt(long min) {
|
public LongPropertyValidator<T> gt(long min) {
|
||||||
return gt(min, () -> new IllegalArgumentException(
|
return gt(min, String.format("The input must be greater than '%d'.", min));
|
||||||
String.format("The input must be greater than '%d'.", min)));
|
|
||||||
}
|
}
|
||||||
|
|
||||||
public LongPropertyValidator<T> gt(long min, String errMsg) {
|
public LongPropertyValidator<T> gt(long min, String errMsg) {
|
||||||
@@ -59,8 +58,7 @@ public class LongPropertyValidator<T>
|
|||||||
// ================================
|
// ================================
|
||||||
|
|
||||||
public LongPropertyValidator<T> ge(long min) {
|
public LongPropertyValidator<T> ge(long min) {
|
||||||
return ge(min, () -> new IllegalArgumentException(
|
return ge(min, String.format("The input must be greater than or equal to '%d'.", min));
|
||||||
String.format("The input must be greater than or equal to '%d'.", min)));
|
|
||||||
}
|
}
|
||||||
|
|
||||||
public LongPropertyValidator<T> ge(long min, String errMsg) {
|
public LongPropertyValidator<T> ge(long min, String errMsg) {
|
||||||
@@ -87,8 +85,7 @@ public class LongPropertyValidator<T>
|
|||||||
// ================================
|
// ================================
|
||||||
|
|
||||||
public LongPropertyValidator<T> lt(long max) {
|
public LongPropertyValidator<T> lt(long max) {
|
||||||
return lt(max, () -> new IllegalArgumentException(
|
return lt(max, String.format("The input must be less than '%d'.", max));
|
||||||
String.format("The input must be less than '%d'.", max)));
|
|
||||||
}
|
}
|
||||||
|
|
||||||
public LongPropertyValidator<T> lt(long max, String errMsg) {
|
public LongPropertyValidator<T> lt(long max, String errMsg) {
|
||||||
@@ -115,8 +112,7 @@ public class LongPropertyValidator<T>
|
|||||||
// ================================
|
// ================================
|
||||||
|
|
||||||
public LongPropertyValidator<T> le(long max) {
|
public LongPropertyValidator<T> le(long max) {
|
||||||
return le(max, () -> new IllegalArgumentException(
|
return le(max, String.format("The input must be less than or equal to '%d'.", max));
|
||||||
String.format("The input must be less than or equal to '%d'.", max)));
|
|
||||||
}
|
}
|
||||||
|
|
||||||
public LongPropertyValidator<T> le(long max, String errMsg) {
|
public LongPropertyValidator<T> le(long max, String errMsg) {
|
||||||
|
@@ -18,7 +18,8 @@ package xyz.zhouxy.plusone.validator;
|
|||||||
|
|
||||||
import java.util.function.Function;
|
import java.util.function.Function;
|
||||||
|
|
||||||
public class ObjectPropertyValidator<T, TProperty> extends BasePropertyValidator<T, TProperty, ObjectPropertyValidator<T, TProperty>> {
|
public class ObjectPropertyValidator<T, TProperty>
|
||||||
|
extends BasePropertyValidator<T, TProperty, ObjectPropertyValidator<T, TProperty>> {
|
||||||
|
|
||||||
ObjectPropertyValidator(Function<T, TProperty> getter) {
|
ObjectPropertyValidator(Function<T, TProperty> getter) {
|
||||||
super(getter);
|
super(getter);
|
||||||
|
@@ -30,7 +30,6 @@ import com.google.common.collect.Lists;
|
|||||||
|
|
||||||
import xyz.zhouxy.plusone.commons.collection.CollectionTools;
|
import xyz.zhouxy.plusone.commons.collection.CollectionTools;
|
||||||
import xyz.zhouxy.plusone.commons.util.DateTimeTools;
|
import xyz.zhouxy.plusone.commons.util.DateTimeTools;
|
||||||
import xyz.zhouxy.plusone.commons.util.StringTools;
|
|
||||||
import xyz.zhouxy.plusone.example.ExampleCommand;
|
import xyz.zhouxy.plusone.example.ExampleCommand;
|
||||||
import xyz.zhouxy.plusone.example.Foo;
|
import xyz.zhouxy.plusone.example.Foo;
|
||||||
import xyz.zhouxy.plusone.validator.BaseValidator;
|
import xyz.zhouxy.plusone.validator.BaseValidator;
|
||||||
|
9
pom.xml
9
pom.xml
@@ -18,7 +18,7 @@
|
|||||||
</modules>
|
</modules>
|
||||||
|
|
||||||
<description>
|
<description>
|
||||||
Plusone Validator 是一个参数校验框架,可针对 DTO 创建对应的校验器,并复用该校验器实例,对 DTO 进行校验。
|
Plusone Validator 是一个校验库,用于构建校验规则对对象(尤其是入参)进行校验。API 参考自 .NET 的 FluentValidation。
|
||||||
</description>
|
</description>
|
||||||
|
|
||||||
<properties>
|
<properties>
|
||||||
@@ -27,6 +27,13 @@
|
|||||||
|
|
||||||
<dependencyManagement>
|
<dependencyManagement>
|
||||||
<dependencies>
|
<dependencies>
|
||||||
|
<dependency>
|
||||||
|
<groupId>org.junit</groupId>
|
||||||
|
<artifactId>junit-bom</artifactId>
|
||||||
|
<version>5.12.1</version>
|
||||||
|
<type>pom</type>
|
||||||
|
<scope>import</scope>
|
||||||
|
</dependency>
|
||||||
<dependency>
|
<dependency>
|
||||||
<groupId>xyz.zhouxy.plusone</groupId>
|
<groupId>xyz.zhouxy.plusone</groupId>
|
||||||
<artifactId>plusone-dependencies</artifactId>
|
<artifactId>plusone-dependencies</artifactId>
|
||||||
|
Reference in New Issue
Block a user