check-same-fields
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/a-int.md---
id: a-int
type: col
fields:
data_type: integer
links:
- type: references
to: b-int
---nodes/b-int.md---
id: b-int
type: col
fields:
data_type: integer
---nodes/c-text.md---
id: c-text
type: col
fields:
data_type: text
links:
- type: references
to: b-int
---nodes/d-bare.md---
id: d-bare
type: col
links:
- type: references
to: b-int
---nodes/r-bad.md---
id: r-bad
type: rule
fields:
statement: s
applies_to: {id: a-int}
check: {require_link: {type: references, same_fields: data_type}}
---nodes/r-need.md---
id: r-need
type: rule
fields:
statement: s
applies_to: {id: [a-int, c-text]}
check: {require_link: {type: references, same_fields: [data_type]}}
---nodes/r-same.md---
id: r-same
type: rule
fields:
statement: s
applies_to: {type: col}
check: {require_link: {type: references, same_fields: [data_type], min: 0, max: 0}}
---Expected output
1 ghosts · 0 load errors · 7 nodes · 7 results
expected.json{
"ghosts": [
{
"link": "references",
"node": "c-text",
"plane": null,
"rule": "r-need",
"to_type": null
}
],
"load_errors": [],
"nodes": [
{
"body": "",
"fields": {
"data_type": "integer"
},
"id": "a-int",
"links": [
{
"to": "b-int",
"type": "references"
}
],
"parent": null,
"plane": null,
"title": "a-int",
"type": "col"
},
{
"body": "",
"fields": {
"data_type": "integer"
},
"id": "b-int",
"links": [],
"parent": null,
"plane": null,
"title": "b-int",
"type": "col"
},
{
"body": "",
"fields": {
"data_type": "text"
},
"id": "c-text",
"links": [
{
"to": "b-int",
"type": "references"
}
],
"parent": null,
"plane": null,
"title": "c-text",
"type": "col"
},
{
"body": "",
"fields": {},
"id": "d-bare",
"links": [
{
"to": "b-int",
"type": "references"
}
],
"parent": null,
"plane": null,
"title": "d-bare",
"type": "col"
},
{
"body": "",
"fields": {
"applies_to": {
"id": "a-int"
},
"check": {
"require_link": {
"same_fields": "data_type",
"type": "references"
}
},
"statement": "s"
},
"id": "r-bad",
"links": [],
"parent": null,
"plane": null,
"title": "r-bad",
"type": "rule"
},
{
"body": "",
"fields": {
"applies_to": {
"id": [
"a-int",
"c-text"
]
},
"check": {
"require_link": {
"same_fields": [
"data_type"
],
"type": "references"
}
},
"statement": "s"
},
"id": "r-need",
"links": [],
"parent": null,
"plane": null,
"title": "r-need",
"type": "rule"
},
{
"body": "",
"fields": {
"applies_to": {
"type": "col"
},
"check": {
"require_link": {
"max": 0,
"min": 0,
"same_fields": [
"data_type"
],
"type": "references"
}
},
"statement": "s"
},
"id": "r-same",
"links": [],
"parent": null,
"plane": null,
"title": "r-same",
"type": "rule"
}
],
"results": [
{
"node": "a-int",
"rule": "r-bad",
"severity": "warn",
"status": "unsupported"
},
{
"node": "a-int",
"rule": "r-need",
"severity": "warn",
"status": "pass"
},
{
"node": "a-int",
"rule": "r-same",
"severity": "warn",
"status": "fail"
},
{
"node": "b-int",
"rule": "r-same",
"severity": "warn",
"status": "pass"
},
{
"node": "c-text",
"rule": "r-need",
"severity": "warn",
"status": "fail"
},
{
"node": "c-text",
"rule": "r-same",
"severity": "warn",
"status": "pass"
},
{
"node": "d-bare",
"rule": "r-same",
"severity": "warn",
"status": "pass"
}
],
"structure": {
"errors": [],
"warnings": []
}
}