|
@@ -95,6 +95,21 @@ public abstract class FormatTester implements Tester {
|
|
|
}
|
|
}
|
|
|
};
|
|
};
|
|
|
|
|
|
|
|
|
|
+ static Tester URI_TEMPLATE = new FormatTester("uri-template") {
|
|
|
|
|
+ @Override
|
|
|
|
|
+ public boolean accepts(JsonNode node) {
|
|
|
|
|
+ if (!node.isTextual()) return false;
|
|
|
|
|
+ try {
|
|
|
|
|
+ // TODO: RFC 2396 -> RFC 3986
|
|
|
|
|
+ // TODO: Validate inside brackets
|
|
|
|
|
+ new java.net.URI(node.asText().replaceAll("\\{.*?\\}", "_temp_"));
|
|
|
|
|
+ return true;
|
|
|
|
|
+ } catch (URISyntaxException e) {
|
|
|
|
|
+ return false;
|
|
|
|
|
+ }
|
|
|
|
|
+ }
|
|
|
|
|
+ };
|
|
|
|
|
+
|
|
|
static Tester JSON_POINTER = new FormatTester("json-pointer") {
|
|
static Tester JSON_POINTER = new FormatTester("json-pointer") {
|
|
|
@Override
|
|
@Override
|
|
|
public boolean accepts(JsonNode node) {
|
|
public boolean accepts(JsonNode node) {
|
|
@@ -114,7 +129,7 @@ public abstract class FormatTester implements Tester {
|
|
|
case "ipv6": return IPV6;
|
|
case "ipv6": return IPV6;
|
|
|
case "uri": return URI;
|
|
case "uri": return URI;
|
|
|
case "uri-reference": return URI_REFERNCE;
|
|
case "uri-reference": return URI_REFERNCE;
|
|
|
-// case "uri-template":
|
|
|
|
|
|
|
+ case "uri-template": return URI_TEMPLATE;
|
|
|
case "json-pointer": return JSON_POINTER;
|
|
case "json-pointer": return JSON_POINTER;
|
|
|
case "uuid": return UUID;
|
|
case "uuid": return UUID;
|
|
|
default: throw new IllegalArgumentException("Unknown format code '" + asText + "'");
|
|
default: throw new IllegalArgumentException("Unknown format code '" + asText + "'");
|