forked from plusone/plusone-validator
feat: 重载校验规则
`BasePropertyValidator#notNull`、`CollectionPropertyValidator#notEmpty` 和 `CollectionPropertyValidator#isEmpty` 提供无参的版本
This commit is contained in:
parent
a28a6135a8
commit
ae970cb393
@ -100,6 +100,10 @@ public abstract class BasePropertyValidator<T, TProperty, TPropertyValidator ext
|
|||||||
// #region - isNull
|
// #region - isNull
|
||||||
// ================================
|
// ================================
|
||||||
|
|
||||||
|
public TPropertyValidator isNull() {
|
||||||
|
return isNull("The input must be null.");
|
||||||
|
}
|
||||||
|
|
||||||
public TPropertyValidator isNull(String errMsg) {
|
public TPropertyValidator isNull(String errMsg) {
|
||||||
return isNull(convertExceptionCreator(errMsg));
|
return isNull(convertExceptionCreator(errMsg));
|
||||||
}
|
}
|
||||||
|
@ -31,11 +31,16 @@ public class CollectionPropertyValidator<T, TElement>
|
|||||||
|
|
||||||
// ====== notEmpty =====
|
// ====== notEmpty =====
|
||||||
|
|
||||||
|
public CollectionPropertyValidator<T, TElement> notEmpty() {
|
||||||
|
return notEmpty("The input must not be empty.");
|
||||||
|
}
|
||||||
|
|
||||||
public CollectionPropertyValidator<T, TElement> notEmpty(String errMsg) {
|
public CollectionPropertyValidator<T, TElement> notEmpty(String errMsg) {
|
||||||
return notEmpty(convertExceptionCreator(errMsg));
|
return notEmpty(convertExceptionCreator(errMsg));
|
||||||
}
|
}
|
||||||
|
|
||||||
public <E extends RuntimeException> CollectionPropertyValidator<T, TElement> notEmpty(Supplier<E> exceptionCreator) {
|
public <E extends RuntimeException> CollectionPropertyValidator<T, TElement> notEmpty(
|
||||||
|
Supplier<E> exceptionCreator) {
|
||||||
return notEmpty(convertExceptionCreator(exceptionCreator));
|
return notEmpty(convertExceptionCreator(exceptionCreator));
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -47,11 +52,16 @@ public class CollectionPropertyValidator<T, TElement>
|
|||||||
|
|
||||||
// ====== isEmpty =====
|
// ====== isEmpty =====
|
||||||
|
|
||||||
|
public CollectionPropertyValidator<T, TElement> isEmpty() {
|
||||||
|
return isEmpty("The input must be empty.");
|
||||||
|
}
|
||||||
|
|
||||||
public CollectionPropertyValidator<T, TElement> isEmpty(String errMsg) {
|
public CollectionPropertyValidator<T, TElement> isEmpty(String errMsg) {
|
||||||
return isEmpty(convertExceptionCreator(errMsg));
|
return isEmpty(convertExceptionCreator(errMsg));
|
||||||
}
|
}
|
||||||
|
|
||||||
public <E extends RuntimeException> CollectionPropertyValidator<T, TElement> isEmpty(Supplier<E> exceptionCreator) {
|
public <E extends RuntimeException> CollectionPropertyValidator<T, TElement> isEmpty(
|
||||||
|
Supplier<E> exceptionCreator) {
|
||||||
return isEmpty(convertExceptionCreator(exceptionCreator));
|
return isEmpty(convertExceptionCreator(exceptionCreator));
|
||||||
}
|
}
|
||||||
|
|
||||||
|
Loading…
x
Reference in New Issue
Block a user