From 0c1a702171b25727fcc7594004e368ca9f9f423c Mon Sep 17 00:00:00 2001 From: Greg Dennis Date: Mon, 18 Mar 2024 09:28:46 +1300 Subject: [PATCH] add more anchor validation tests --- tests/draft2019-09/anchor.json | 54 ++++++++++++++++++++++++++++++++-- tests/draft2020-12/anchor.json | 49 ++++++++++++++++++++++++++++-- 2 files changed, 99 insertions(+), 4 deletions(-) diff --git a/tests/draft2019-09/anchor.json b/tests/draft2019-09/anchor.json index eb0a969a..1080580d 100644 --- a/tests/draft2019-09/anchor.json +++ b/tests/draft2019-09/anchor.json @@ -118,7 +118,7 @@ ] }, { - "description": "invalid anchors", + "description": "anchor validity", "comment": "Section 8.2.3", "schema": { "$schema": "https://json-schema.org/draft/2019-09/schema", @@ -126,10 +126,60 @@ }, "tests": [ { - "description": "MUST start with a letter (and not #)", + "description": "MUST NOT start with #", "data": { "$anchor" : "#foo" }, "valid": false }, + { + "description": "MUST NOT start with number", + "data": { "$anchor" : "0number" }, + "valid": false + }, + { + "description": "MUST NOT start with period", + "data": { "$anchor" : ".period" }, + "valid": false + }, + { + "description": "MUST NOT start with hyphen", + "data": { "$anchor" : "-hyphen" }, + "valid": false + }, + { + "description": "MUST NOT start with underscore", + "data": { "$anchor" : "_underscore" }, + "valid": false + }, + { + "description": "MUST NOT start with colon", + "data": { "$anchor" : ":colon" }, + "valid": false + }, + { + "description": "MAY contain colon", + "data": { "$anchor" : "inner:colon" }, + "valid": true + }, + { + "description": "MAY contain underscore", + "data": { "$anchor" : "under_score" }, + "valid": true + }, + { + "description": "MAY contain hyphen", + "data": { "$anchor" : "inner-hyphen" }, + "valid": true + }, + { + "description": "MAY contain period", + "data": { "$anchor" : "inner.period" }, + "valid": true + }, + { + "description": "MAY contain numbers", + "data": { "$anchor" : "start0123456789end" }, + "valid": true + }, { "description": "JSON pointers are not valid", "data": { "$anchor" : "/a/b" }, diff --git a/tests/draft2020-12/anchor.json b/tests/draft2020-12/anchor.json index 83a7166d..22b1389f 100644 --- a/tests/draft2020-12/anchor.json +++ b/tests/draft2020-12/anchor.json @@ -118,7 +118,7 @@ ] }, { - "description": "invalid anchors", + "description": "anchor validity", "comment": "Section 8.2.2", "schema": { "$schema": "https://json-schema.org/draft/2020-12/schema", @@ -126,10 +126,55 @@ }, "tests": [ { - "description": "MUST start with a letter (and not #)", + "description": "MUST NOT start with #", "data": { "$anchor" : "#foo" }, "valid": false }, + { + "description": "MUST NOT start with number", + "data": { "$anchor" : "0number" }, + "valid": false + }, + { + "description": "MUST NOT start with period", + "data": { "$anchor" : ".period" }, + "valid": false + }, + { + "description": "MUST NOT start with hyphen", + "data": { "$anchor" : "-hyphen" }, + "valid": false + }, + { + "description": "MAY start with underscore", + "data": { "$anchor" : "_underscore" }, + "valid": true + }, + { + "description": "MUST NOT contain colon", + "data": { "$anchor" : "inner:colon" }, + "valid": false + }, + { + "description": "MAY contain underscore", + "data": { "$anchor" : "under_score" }, + "valid": true + }, + { + "description": "MAY contain hyphen", + "data": { "$anchor" : "inner-hyphen" }, + "valid": true + }, + { + "description": "MAY contain period", + "data": { "$anchor" : "inner.period" }, + "valid": true + }, + { + "description": "MAY contain numbers", + "data": { "$anchor" : "start0123456789end" }, + "valid": true + }, { "description": "JSON pointers are not valid", "data": { "$anchor" : "/a/b" },