check-any-of
Tests one check in the rule vocabulary: how it decides, and what it reports.
Our implementation passes this case when its check --json output for the input below equals the expected
output.
Input
nodes/n1.md---
id: n1
type: t
links:
- type: a
to: t3
---nodes/n2.md---
id: n2
type: t
links:
- type: b
to: t3
---nodes/n3.md---
id: n3
type: t
---nodes/n4.md---
id: n4
type: t
fields:
x: 1
---nodes/r-and-inside.md---
id: r-and-inside
type: rule
fields:
statement: s
applies_to: {type: t}
check: {any_of: [{require_fields: [x], require_link: {type: a}}, {require_link: {type: b}}]}
---nodes/r-either.md---
id: r-either
type: rule
fields:
statement: s
severity: error
applies_to: {type: t}
check: {any_of: [{require_link: {type: a}}, {require_link: {type: b}}]}
---nodes/r-empty-item.md---
id: r-empty-item
type: rule
fields:
statement: s
applies_to: {type: t}
check: {any_of: [{}, {require_link: {type: a}}]}
---nodes/r-empty.md---
id: r-empty
type: rule
fields:
statement: s
applies_to: {type: t}
check: {any_of: []}
---nodes/r-fields-or-link.md---
id: r-fields-or-link
type: rule
fields:
statement: s
applies_to: {type: t}
check: {any_of: [{require_fields: [x]}, {require_link: {type: a}}]}
---nodes/r-nested.md---
id: r-nested
type: rule
fields:
statement: s
applies_to: {type: t}
check: {any_of: [{any_of: [{require_link: {type: a}}, {require_link: {type: b}}]}, {require_fields: [x]}]}
---nodes/r-not-list.md---
id: r-not-list
type: rule
fields:
statement: s
applies_to: {type: t}
check: {any_of: {require_link: {type: a}}}
---nodes/r-with-bad-part.md---
id: r-with-bad-part
type: rule
fields:
statement: s
applies_to: {type: t}
check: {any_of: [{require_link: {type: a}}, {nonsense: 1}]}
---nodes/r-with-sibling.md---
id: r-with-sibling
type: rule
fields:
statement: s
applies_to: {type: t}
check: {any_of: [{require_link: {type: b}}], require_fields: [x]}
---nodes/t3.md---
id: t3
type: u
---Expected output
0 ghosts · 0 load errors · 14 nodes · 36 results
expected.json{
"ghosts": [],
"load_errors": [],
"nodes": [
{
"body": "",
"fields": {},
"id": "n1",
"links": [
{
"to": "t3",
"type": "a"
}
],
"parent": null,
"plane": null,
"title": "n1",
"type": "t"
},
{
"body": "",
"fields": {},
"id": "n2",
"links": [
{
"to": "t3",
"type": "b"
}
],
"parent": null,
"plane": null,
"title": "n2",
"type": "t"
},
{
"body": "",
"fields": {},
"id": "n3",
"links": [],
"parent": null,
"plane": null,
"title": "n3",
"type": "t"
},
{
"body": "",
"fields": {
"x": 1
},
"id": "n4",
"links": [],
"parent": null,
"plane": null,
"title": "n4",
"type": "t"
},
{
"body": "",
"fields": {
"applies_to": {
"type": "t"
},
"check": {
"any_of": [
{
"require_fields": [
"x"
],
"require_link": {
"type": "a"
}
},
{
"require_link": {
"type": "b"
}
}
]
},
"statement": "s"
},
"id": "r-and-inside",
"links": [],
"parent": null,
"plane": null,
"title": "r-and-inside",
"type": "rule"
},
{
"body": "",
"fields": {
"applies_to": {
"type": "t"
},
"check": {
"any_of": [
{
"require_link": {
"type": "a"
}
},
{
"require_link": {
"type": "b"
}
}
]
},
"severity": "error",
"statement": "s"
},
"id": "r-either",
"links": [],
"parent": null,
"plane": null,
"title": "r-either",
"type": "rule"
},
{
"body": "",
"fields": {
"applies_to": {
"type": "t"
},
"check": {
"any_of": []
},
"statement": "s"
},
"id": "r-empty",
"links": [],
"parent": null,
"plane": null,
"title": "r-empty",
"type": "rule"
},
{
"body": "",
"fields": {
"applies_to": {
"type": "t"
},
"check": {
"any_of": [
{},
{
"require_link": {
"type": "a"
}
}
]
},
"statement": "s"
},
"id": "r-empty-item",
"links": [],
"parent": null,
"plane": null,
"title": "r-empty-item",
"type": "rule"
},
{
"body": "",
"fields": {
"applies_to": {
"type": "t"
},
"check": {
"any_of": [
{
"require_fields": [
"x"
]
},
{
"require_link": {
"type": "a"
}
}
]
},
"statement": "s"
},
"id": "r-fields-or-link",
"links": [],
"parent": null,
"plane": null,
"title": "r-fields-or-link",
"type": "rule"
},
{
"body": "",
"fields": {
"applies_to": {
"type": "t"
},
"check": {
"any_of": [
{
"any_of": [
{
"require_link": {
"type": "a"
}
},
{
"require_link": {
"type": "b"
}
}
]
},
{
"require_fields": [
"x"
]
}
]
},
"statement": "s"
},
"id": "r-nested",
"links": [],
"parent": null,
"plane": null,
"title": "r-nested",
"type": "rule"
},
{
"body": "",
"fields": {
"applies_to": {
"type": "t"
},
"check": {
"any_of": {
"require_link": {
"type": "a"
}
}
},
"statement": "s"
},
"id": "r-not-list",
"links": [],
"parent": null,
"plane": null,
"title": "r-not-list",
"type": "rule"
},
{
"body": "",
"fields": {
"applies_to": {
"type": "t"
},
"check": {
"any_of": [
{
"require_link": {
"type": "a"
}
},
{
"nonsense": 1
}
]
},
"statement": "s"
},
"id": "r-with-bad-part",
"links": [],
"parent": null,
"plane": null,
"title": "r-with-bad-part",
"type": "rule"
},
{
"body": "",
"fields": {
"applies_to": {
"type": "t"
},
"check": {
"any_of": [
{
"require_link": {
"type": "b"
}
}
],
"require_fields": [
"x"
]
},
"statement": "s"
},
"id": "r-with-sibling",
"links": [],
"parent": null,
"plane": null,
"title": "r-with-sibling",
"type": "rule"
},
{
"body": "",
"fields": {},
"id": "t3",
"links": [],
"parent": null,
"plane": null,
"title": "t3",
"type": "u"
}
],
"results": [
{
"node": "n1",
"rule": "r-and-inside",
"severity": "warn",
"status": "fail"
},
{
"node": "n1",
"rule": "r-either",
"severity": "error",
"status": "pass"
},
{
"node": "n1",
"rule": "r-empty",
"severity": "warn",
"status": "unsupported"
},
{
"node": "n1",
"rule": "r-empty-item",
"severity": "warn",
"status": "unsupported"
},
{
"node": "n1",
"rule": "r-fields-or-link",
"severity": "warn",
"status": "pass"
},
{
"node": "n1",
"rule": "r-nested",
"severity": "warn",
"status": "pass"
},
{
"node": "n1",
"rule": "r-not-list",
"severity": "warn",
"status": "unsupported"
},
{
"node": "n1",
"rule": "r-with-bad-part",
"severity": "warn",
"status": "pass"
},
{
"node": "n1",
"rule": "r-with-sibling",
"severity": "warn",
"status": "fail"
},
{
"node": "n2",
"rule": "r-and-inside",
"severity": "warn",
"status": "pass"
},
{
"node": "n2",
"rule": "r-either",
"severity": "error",
"status": "pass"
},
{
"node": "n2",
"rule": "r-empty",
"severity": "warn",
"status": "unsupported"
},
{
"node": "n2",
"rule": "r-empty-item",
"severity": "warn",
"status": "unsupported"
},
{
"node": "n2",
"rule": "r-fields-or-link",
"severity": "warn",
"status": "fail"
},
{
"node": "n2",
"rule": "r-nested",
"severity": "warn",
"status": "pass"
},
{
"node": "n2",
"rule": "r-not-list",
"severity": "warn",
"status": "unsupported"
},
{
"node": "n2",
"rule": "r-with-bad-part",
"severity": "warn",
"status": "unsupported"
},
{
"node": "n2",
"rule": "r-with-sibling",
"severity": "warn",
"status": "fail"
},
{
"node": "n3",
"rule": "r-and-inside",
"severity": "warn",
"status": "fail"
},
{
"node": "n3",
"rule": "r-either",
"severity": "error",
"status": "fail"
},
{
"node": "n3",
"rule": "r-empty",
"severity": "warn",
"status": "unsupported"
},
{
"node": "n3",
"rule": "r-empty-item",
"severity": "warn",
"status": "unsupported"
},
{
"node": "n3",
"rule": "r-fields-or-link",
"severity": "warn",
"status": "fail"
},
{
"node": "n3",
"rule": "r-nested",
"severity": "warn",
"status": "fail"
},
{
"node": "n3",
"rule": "r-not-list",
"severity": "warn",
"status": "unsupported"
},
{
"node": "n3",
"rule": "r-with-bad-part",
"severity": "warn",
"status": "unsupported"
},
{
"node": "n3",
"rule": "r-with-sibling",
"severity": "warn",
"status": "fail"
},
{
"node": "n4",
"rule": "r-and-inside",
"severity": "warn",
"status": "fail"
},
{
"node": "n4",
"rule": "r-either",
"severity": "error",
"status": "fail"
},
{
"node": "n4",
"rule": "r-empty",
"severity": "warn",
"status": "unsupported"
},
{
"node": "n4",
"rule": "r-empty-item",
"severity": "warn",
"status": "unsupported"
},
{
"node": "n4",
"rule": "r-fields-or-link",
"severity": "warn",
"status": "pass"
},
{
"node": "n4",
"rule": "r-nested",
"severity": "warn",
"status": "pass"
},
{
"node": "n4",
"rule": "r-not-list",
"severity": "warn",
"status": "unsupported"
},
{
"node": "n4",
"rule": "r-with-bad-part",
"severity": "warn",
"status": "unsupported"
},
{
"node": "n4",
"rule": "r-with-sibling",
"severity": "warn",
"status": "fail"
}
],
"structure": {
"errors": [],
"warnings": []
}
}