From d81e6acc234aba7952cb948ae3a3a96b54b7be54 Mon Sep 17 00:00:00 2001 From: ZhouXY108 Date: Wed, 28 May 2025 02:36:14 +0800 Subject: [PATCH] =?UTF-8?q?fix:=20`StringPropertyValidator`=20=E9=BB=98?= =?UTF-8?q?=E8=AE=A4=E5=8C=B9=E9=85=8D=E6=AD=A3=E5=88=99=E6=97=B6=E4=B8=8D?= =?UTF-8?q?=E5=AF=B9=20`null`=20=E8=BF=9B=E8=A1=8C=E6=A0=A1=E9=AA=8C?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../zhouxy/plusone/validator/StringPropertyValidator.java | 8 ++++---- 1 file changed, 4 insertions(+), 4 deletions(-) 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; }