Private beta, by invitation. It may change without warning. While the beta lasts, some paid features are free. See pricing

trumlyspec GitHub
Try trumly

Conformance cases /

check-link-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.md
---
id: a
type: state
links:
  - type: goes
    to: b
    fields: {on: go}
  - type: goes
    to: c
    fields: {on: stop}
---
nodes/b.md
---
id: b
type: state
links:
  - type: goes
    to: a
    fields: {on: ''}
  - type: goes
    to: c
---
nodes/c.md
---
id: c
type: state
links:
  - type: goes
    to: a
    fields: {on: go}
---
nodes/d.md
---
id: d
type: state
links:
  - type: other
    to: a
---
nodes/r1.md
---
id: r1
type: rule
fields:
  statement: s
  applies_to: {type: state}
  check: {require_link_fields: {type: goes, fields: [on]}}
---
nodes/r2.md
---
id: r2
type: rule
fields:
  statement: s
  applies_to: {type: state}
  check: {require_link: {type: goes, with_fields: [on], min: 2}}
---

Expected output

3 ghosts · 0 load errors · 6 nodes · 8 results

expected.json
{
 "ghosts": [
  {
   "link": "goes",
   "node": "b",
   "plane": null,
   "rule": "r2",
   "to_type": null
  },
  {
   "link": "goes",
   "node": "c",
   "plane": null,
   "rule": "r2",
   "to_type": null
  },
  {
   "link": "goes",
   "node": "d",
   "plane": null,
   "rule": "r2",
   "to_type": null
  }
 ],
 "load_errors": [],
 "nodes": [
  {
   "body": "",
   "fields": {},
   "id": "a",
   "links": [
    {
     "fields": {
      "on": "go"
     },
     "to": "b",
     "type": "goes"
    },
    {
     "fields": {
      "on": "stop"
     },
     "to": "c",
     "type": "goes"
    }
   ],
   "parent": null,
   "plane": null,
   "title": "a",
   "type": "state"
  },
  {
   "body": "",
   "fields": {},
   "id": "b",
   "links": [
    {
     "fields": {
      "on": ""
     },
     "to": "a",
     "type": "goes"
    },
    {
     "to": "c",
     "type": "goes"
    }
   ],
   "parent": null,
   "plane": null,
   "title": "b",
   "type": "state"
  },
  {
   "body": "",
   "fields": {},
   "id": "c",
   "links": [
    {
     "fields": {
      "on": "go"
     },
     "to": "a",
     "type": "goes"
    }
   ],
   "parent": null,
   "plane": null,
   "title": "c",
   "type": "state"
  },
  {
   "body": "",
   "fields": {},
   "id": "d",
   "links": [
    {
     "to": "a",
     "type": "other"
    }
   ],
   "parent": null,
   "plane": null,
   "title": "d",
   "type": "state"
  },
  {
   "body": "",
   "fields": {
    "applies_to": {
     "type": "state"
    },
    "check": {
     "require_link_fields": {
      "fields": [
       "on"
      ],
      "type": "goes"
     }
    },
    "statement": "s"
   },
   "id": "r1",
   "links": [],
   "parent": null,
   "plane": null,
   "title": "r1",
   "type": "rule"
  },
  {
   "body": "",
   "fields": {
    "applies_to": {
     "type": "state"
    },
    "check": {
     "require_link": {
      "min": 2,
      "type": "goes",
      "with_fields": [
       "on"
      ]
     }
    },
    "statement": "s"
   },
   "id": "r2",
   "links": [],
   "parent": null,
   "plane": null,
   "title": "r2",
   "type": "rule"
  }
 ],
 "results": [
  {
   "node": "a",
   "rule": "r1",
   "severity": "warn",
   "status": "pass"
  },
  {
   "node": "a",
   "rule": "r2",
   "severity": "warn",
   "status": "pass"
  },
  {
   "node": "b",
   "rule": "r1",
   "severity": "warn",
   "status": "fail"
  },
  {
   "node": "b",
   "rule": "r2",
   "severity": "warn",
   "status": "fail"
  },
  {
   "node": "c",
   "rule": "r1",
   "severity": "warn",
   "status": "pass"
  },
  {
   "node": "c",
   "rule": "r2",
   "severity": "warn",
   "status": "fail"
  },
  {
   "node": "d",
   "rule": "r1",
   "severity": "warn",
   "status": "pass"
  },
  {
   "node": "d",
   "rule": "r2",
   "severity": "warn",
   "status": "fail"
  }
 ],
 "structure": {
  "errors": [],
  "warnings": []
 }
}