diff --git a/vocabulary/format-assertion/src/main/java/io/github/sebastiantoepfer/jsonschema/vocabulary/formatassertion/Formats.java b/vocabulary/format-assertion/src/main/java/io/github/sebastiantoepfer/jsonschema/vocabulary/formatassertion/Formats.java index fe3982f..1148cc6 100644 --- a/vocabulary/format-assertion/src/main/java/io/github/sebastiantoepfer/jsonschema/vocabulary/formatassertion/Formats.java +++ b/vocabulary/format-assertion/src/main/java/io/github/sebastiantoepfer/jsonschema/vocabulary/formatassertion/Formats.java @@ -42,7 +42,8 @@ final class Formats { Map.entry("email", Map.entry(5321, "mailbox")), Map.entry("ipv4", Map.entry(2673, "dotted-quad")), Map.entry("uuid", Map.entry(4122, "UUID")), - Map.entry("ipv6", Map.entry(4291, "IPv6address")) + Map.entry("ipv6", Map.entry(4291, "IPv6address")), + Map.entry("json-pointer", Map.entry(6901, "json-pointer")) ); Format findByName(final String name) { diff --git a/vocabulary/format-assertion/src/main/java/io/github/sebastiantoepfer/jsonschema/vocabulary/formatassertion/rfc/Rfcs.java b/vocabulary/format-assertion/src/main/java/io/github/sebastiantoepfer/jsonschema/vocabulary/formatassertion/rfc/Rfcs.java index cce9c1e..d64c989 100644 --- a/vocabulary/format-assertion/src/main/java/io/github/sebastiantoepfer/jsonschema/vocabulary/formatassertion/rfc/Rfcs.java +++ b/vocabulary/format-assertion/src/main/java/io/github/sebastiantoepfer/jsonschema/vocabulary/formatassertion/rfc/Rfcs.java @@ -258,6 +258,10 @@ public final class Rfcs { ) ) ) + ), + Map.entry( + 6901, + Map.of("json-pointer", new RegExRule(Pattern.compile("^(/([\\x00-.0-}\\x7f-\\u010ffff]|\\~[01])*)*$"))) ) ); diff --git a/vocabulary/format-assertion/src/main/resources/rfc/rfc6901 b/vocabulary/format-assertion/src/main/resources/rfc/rfc6901 new file mode 100644 index 0000000..85ab0bf --- /dev/null +++ b/vocabulary/format-assertion/src/main/resources/rfc/rfc6901 @@ -0,0 +1,6 @@ +json-pointer = *( "/" reference-token ) +reference-token = *( unescaped / escaped ) +unescaped = %x00-2E / %x30-7D / %x7F-10FFFF + ; %x2F ('/') and %x7E ('~') are excluded from 'unescaped' +escaped = "~" ( "0" / "1" ) + ; representing '~' and '/', respectively diff --git a/vocabulary/format-assertion/src/test/java/io/github/sebastiantoepfer/jsonschema/vocabulary/formatassertion/FormatsTest.java b/vocabulary/format-assertion/src/test/java/io/github/sebastiantoepfer/jsonschema/vocabulary/formatassertion/FormatsTest.java index 53396a0..63de9d5 100644 --- a/vocabulary/format-assertion/src/test/java/io/github/sebastiantoepfer/jsonschema/vocabulary/formatassertion/FormatsTest.java +++ b/vocabulary/format-assertion/src/test/java/io/github/sebastiantoepfer/jsonschema/vocabulary/formatassertion/FormatsTest.java @@ -121,4 +121,10 @@ void should_found_uuidformat() { assertThat(new Formats().findByName("uuid").applyTo("b7128c5b-eafc-4b6b-9b35-1c9e3dbaabb1"), is(true)); assertThat(new Formats().findByName("uuid").applyTo("b7128c5b-eafc-4b6b-9b35"), is(false)); } + + @Test + void should_found_jsonpointerformat() { + assertThat(new Formats().findByName("json-pointer").applyTo("/abc"), is(true)); + assertThat(new Formats().findByName("json-pointer:").applyTo("abc"), is(false)); + } }