forked from plusone/plusone-validator
fix: StringPropertyValidator
默认匹配正则时不对 null
进行校验
This commit is contained in:
parent
124ce63323
commit
d81e6acc23
@ -84,7 +84,7 @@ public class StringPropertyValidator<T> extends BaseComparablePropertyValidator<
|
|||||||
public <E extends RuntimeException> StringPropertyValidator<T> matchesOne(
|
public <E extends RuntimeException> StringPropertyValidator<T> matchesOne(
|
||||||
Pattern[] regexs,
|
Pattern[] regexs,
|
||||||
Function<String, E> exceptionCreator) {
|
Function<String, E> exceptionCreator) {
|
||||||
withRule(input -> RegexTools.matchesOne(input, regexs), exceptionCreator);
|
withRule(input -> input == null || RegexTools.matchesOne(input, regexs), exceptionCreator);
|
||||||
return this;
|
return this;
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -126,7 +126,7 @@ public class StringPropertyValidator<T> extends BaseComparablePropertyValidator<
|
|||||||
public <E extends RuntimeException> StringPropertyValidator<T> matchesAll(
|
public <E extends RuntimeException> StringPropertyValidator<T> matchesAll(
|
||||||
Pattern[] regexs,
|
Pattern[] regexs,
|
||||||
Function<String, E> exceptionCreator) {
|
Function<String, E> exceptionCreator) {
|
||||||
withRule(input -> RegexTools.matchesAll(input, regexs), exceptionCreator);
|
withRule(input -> input == null || RegexTools.matchesAll(input, regexs), exceptionCreator);
|
||||||
return this;
|
return this;
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -269,8 +269,8 @@ public class StringPropertyValidator<T> extends BaseComparablePropertyValidator<
|
|||||||
|
|
||||||
public <E extends RuntimeException> StringPropertyValidator<T> length(int min, int max,
|
public <E extends RuntimeException> StringPropertyValidator<T> length(int min, int max,
|
||||||
Function<String, E> exceptionCreator) {
|
Function<String, E> exceptionCreator) {
|
||||||
AssertTools.checkArgument(min >= 0, "The minimum value must be greater than equal to 0.");
|
AssertTools.checkArgument(min >= 0, "The 'min' must be greater than or equal to 0.");
|
||||||
AssertTools.checkArgument(min < max, "The minimum value must be less than the maximum value.");
|
AssertTools.checkArgument(min <= max, "The 'min' must be less than or equal to the 'max'.");
|
||||||
withRule(s -> length(s, min, max), exceptionCreator);
|
withRule(s -> length(s, min, max), exceptionCreator);
|
||||||
return this;
|
return this;
|
||||||
}
|
}
|
||||||
|
Loading…
x
Reference in New Issue
Block a user