feat: 重载校验规则

`BasePropertyValidator#notNull`、`CollectionPropertyValidator#notEmpty` 和 `CollectionPropertyValidator#isEmpty` 提供无参的版本
This commit is contained in:
zhouxy108 2025-05-27 23:53:58 +08:00
parent a28a6135a8
commit ae970cb393
2 changed files with 16 additions and 2 deletions

View File

@ -100,6 +100,10 @@ public abstract class BasePropertyValidator<T, TProperty, TPropertyValidator ext
// #region - isNull
// ================================
public TPropertyValidator isNull() {
return isNull("The input must be null.");
}
public TPropertyValidator isNull(String errMsg) {
return isNull(convertExceptionCreator(errMsg));
}

View File

@ -31,11 +31,16 @@ public class CollectionPropertyValidator<T, TElement>
// ====== notEmpty =====
public CollectionPropertyValidator<T, TElement> notEmpty() {
return notEmpty("The input must not be empty.");
}
public CollectionPropertyValidator<T, TElement> notEmpty(String 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));
}
@ -47,11 +52,16 @@ public class CollectionPropertyValidator<T, TElement>
// ====== isEmpty =====
public CollectionPropertyValidator<T, TElement> isEmpty() {
return isEmpty("The input must be empty.");
}
public CollectionPropertyValidator<T, TElement> isEmpty(String 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));
}