Add support for v4 UUIDs, and allow UUIDs to be case insensitive (#1688)

This commit is contained in:
Jamie Tanna
2021-08-06 17:54:23 +01:00
committed by GitHub
parent 930eea8d3c
commit 13054ddb29
2 changed files with 31 additions and 3 deletions

View File

@@ -66,7 +66,10 @@ public final class RegexPatterns {
protected static final Pattern HTTPS_URL = UrlHelper.HTTPS_URL;
protected static final Pattern UUID = Pattern
.compile("[a-f0-9]{8}-[a-f0-9]{4}-[a-f0-9]{4}-[a-f0-9]{4}-[a-f0-9]{12}");
.compile("[a-f0-9]{8}-[a-f0-9]{4}-[a-f0-9]{4}-[a-f0-9]{4}-[a-f0-9]{12}", Pattern.CASE_INSENSITIVE);
protected static final Pattern UUID4 = Pattern
.compile("[a-f0-9]{8}-[a-f0-9]{4}-4[a-f0-9]{3}-[89ab][a-f0-9]{3}-[a-f0-9]{12}", Pattern.CASE_INSENSITIVE);
protected static final Pattern ANY_DATE = Pattern
.compile("(\\d\\d\\d\\d)-(0[1-9]|1[012])-(0[1-9]|[12][0-9]|3[01])");
@@ -164,6 +167,10 @@ public final class RegexPatterns {
return new RegexProperty(UUID).asString();
}
public static RegexProperty uuid4() {
return new RegexProperty(UUID4).asString();
}
public static RegexProperty isoDate() {
return new RegexProperty(ANY_DATE).asString();
}