使用 RegexUtil 做正则校验。

feature/net-util
ZhouXY108 2023-06-29 01:18:08 +08:00
parent 13fc8e40b5
commit 672a16ad19
1 changed files with 2 additions and 1 deletions

View File

@ -21,6 +21,7 @@ import java.util.regex.Pattern;
import com.fasterxml.jackson.annotation.JsonValue; import com.fasterxml.jackson.annotation.JsonValue;
import xyz.zhouxy.plusone.commons.util.Assert; import xyz.zhouxy.plusone.commons.util.Assert;
import xyz.zhouxy.plusone.commons.util.RegexUtil;
/** /**
* *
@ -34,7 +35,7 @@ public abstract class ValidatableStringRecord {
protected ValidatableStringRecord(String value, Pattern pattern) { protected ValidatableStringRecord(String value, Pattern pattern) {
Assert.notNull(pattern, "The pattern must not be null."); Assert.notNull(pattern, "The pattern must not be null.");
Assert.isNotBlank(value, "The value must be has text."); Assert.isNotBlank(value, "The value must be has text.");
Assert.isTrue(pattern.matcher(value).matches()); Assert.isTrue(RegexUtil.matches(value, pattern));
this.value = value; this.value = value;
} }