Skip to content

add more anchor validation tests #724

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Closed
wants to merge 1 commit into from
Closed
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
54 changes: 52 additions & 2 deletions tests/draft2019-09/anchor.json
Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Technically the 2019-09 format is the same for previous versions, but it's in $id instead. I can try to make those changes as well, if desired.

Original file line number Diff line number Diff line change
Expand Up @@ -118,18 +118,68 @@
]
},
{
"description": "invalid anchors",
"description": "anchor validity",
"comment": "Section 8.2.3",
"schema": {
"$schema": "https://json-schema.org/draft/2019-09/schema",
"$ref": "https://json-schema.org/draft/2019-09/schema"
},
"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" },
Expand Down
49 changes: 47 additions & 2 deletions tests/draft2020-12/anchor.json
Original file line number Diff line number Diff line change
Expand Up @@ -118,18 +118,63 @@
]
},
{
"description": "invalid anchors",
"description": "anchor validity",
"comment": "Section 8.2.2",
"schema": {
"$schema": "https://json-schema.org/draft/2020-12/schema",
"$ref": "https://json-schema.org/draft/2020-12/schema"
},
"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" },
Expand Down