diff --git a/src/main/java/xyz/zhouxy/plusone/validator/StringValidator.java b/src/main/java/xyz/zhouxy/plusone/validator/StringValidator.java index e3c51c5..b833533 100644 --- a/src/main/java/xyz/zhouxy/plusone/validator/StringValidator.java +++ b/src/main/java/xyz/zhouxy/plusone/validator/StringValidator.java @@ -1,5 +1,6 @@ package xyz.zhouxy.plusone.validator; +import java.util.Collection; import java.util.List; import java.util.function.Function; import java.util.function.Supplier; @@ -58,18 +59,18 @@ public class StringValidator extends PropertyValidator matchesOr(List regexs, String errMsg) { + public StringValidator matchesOr(List regexs, String errMsg) { return matchesOr(regexs, convertExceptionCreator(errMsg)); } public StringValidator matchesOr( - List regexs, + List regexs, Supplier exceptionCreator) { return matchesOr(regexs, convertExceptionCreator(exceptionCreator)); } public StringValidator matchesOr( - List regexs, + List regexs, Function exceptionCreator) { withRule(input -> RegexUtil.matchesOr(input, regexs.toArray(new Pattern[regexs.size()])), exceptionCreator); return this; @@ -94,6 +95,23 @@ public class StringValidator extends PropertyValidator matchesAnd(Collection regexs, String errMsg) { + return matchesAnd(regexs, convertExceptionCreator(errMsg)); + } + + public StringValidator matchesAnd( + Collection regexs, + Supplier exceptionCreator) { + return matchesAnd(regexs, convertExceptionCreator(exceptionCreator)); + } + + public StringValidator matchesAnd( + Collection regexs, + Function exceptionCreator) { + withRule(input -> RegexUtil.matchesAnd(input, regexs.toArray(new Pattern[regexs.size()])), exceptionCreator); + return this; + } + // ===== notBlank ===== public StringValidator notBlank() {