diff --git a/plusone-validator/src/main/java/xyz/zhouxy/plusone/validator/StringPropertyValidator.java b/plusone-validator/src/main/java/xyz/zhouxy/plusone/validator/StringPropertyValidator.java index eaf35b5..1e3623c 100644 --- a/plusone-validator/src/main/java/xyz/zhouxy/plusone/validator/StringPropertyValidator.java +++ b/plusone-validator/src/main/java/xyz/zhouxy/plusone/validator/StringPropertyValidator.java @@ -84,7 +84,7 @@ public class StringPropertyValidator extends BaseComparablePropertyValidator< public StringPropertyValidator matchesOne( Pattern[] regexs, Function exceptionCreator) { - withRule(input -> RegexTools.matchesOne(input, regexs), exceptionCreator); + withRule(input -> input == null || RegexTools.matchesOne(input, regexs), exceptionCreator); return this; } @@ -126,7 +126,7 @@ public class StringPropertyValidator extends BaseComparablePropertyValidator< public StringPropertyValidator matchesAll( Pattern[] regexs, Function exceptionCreator) { - withRule(input -> RegexTools.matchesAll(input, regexs), exceptionCreator); + withRule(input -> input == null || RegexTools.matchesAll(input, regexs), exceptionCreator); return this; } @@ -269,8 +269,8 @@ public class StringPropertyValidator extends BaseComparablePropertyValidator< public StringPropertyValidator length(int min, int max, Function exceptionCreator) { - AssertTools.checkArgument(min >= 0, "The minimum value must be greater than equal to 0."); - AssertTools.checkArgument(min < max, "The minimum value must be less than the maximum value."); + AssertTools.checkArgument(min >= 0, "The 'min' must be greater than or equal to 0."); + AssertTools.checkArgument(min <= max, "The 'min' must be less than or equal to the 'max'."); withRule(s -> length(s, min, max), exceptionCreator); return this; }