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 /

applies-to-any-of

Tests one part of the structure checks.

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: svc
parent: g
plane: p1
fields:
  tier: gold
  methods: [{verb: GET}, {verb: PUT}]
  tags: [x, y]
---
nodes/b.md
---
id: b
type: queue
plane: p2
fields:
  tier: silver
  methods: [{verb: GET}]
  tags: [z]
---
nodes/c.md
---
id: c
type: cache
parent: a
plane: p2
fields:
  tier: bronze
  methods: [{verb: DELETE}]
  tags: []
---
nodes/d.md
---
id: d
type: other
plane: p1
fields:
  tier: gold
---
nodes/g.md
---
id: g
type: group
---
nodes/p1.md
---
id: p1
type: plane
fields:
  order: 1
---
nodes/p2.md
---
id: p2
type: plane
fields:
  order: 2
---
nodes/r1.md
---
id: r1
type: rule
fields:
  statement: s
  applies_to: {type: [svc, queue]}
  check: {require_fields: [owner]}
---
nodes/r2.md
---
id: r2
type: rule
fields:
  statement: s
  applies_to: {type: [svc, queue], plane: [p2, p9]}
  check: {require_fields: [owner]}
---
nodes/r3.md
---
id: r3
type: rule
fields:
  statement: s
  applies_to: {tier: [gold, silver]}
  check: {require_fields: [owner]}
---
nodes/r4.md
---
id: r4
type: rule
fields:
  statement: s
  applies_to: {'methods[].verb': [PUT, DELETE]}
  check: {require_fields: [owner]}
---
nodes/r5.md
---
id: r5
type: rule
fields:
  statement: s
  applies_to: {'tags[]': [x, z]}
  check: {require_fields: [owner]}
---
nodes/r6.md
---
id: r6
type: rule
fields:
  statement: s
  applies_to: {under: [g, a]}
  check: {require_fields: [owner]}
---
nodes/r7.md
---
id: r7
type: rule
fields:
  statement: s
  applies_to: {id: [a, d, nope]}
  check: {require_fields: [owner]}
---
nodes/r8.md
---
id: r8
type: rule
fields:
  statement: s
  applies_to: {type: []}
  check: {require_fields: [owner]}
---
nodes/r9.md
---
id: r9
type: rule
fields:
  statement: s
  applies_to: {type: svc}
  check: {require_fields: [owner]}
---

Expected output

0 ghosts · 0 load errors · 16 nodes · 15 results

expected.json
{
 "ghosts": [],
 "load_errors": [],
 "nodes": [
  {
   "body": "",
   "fields": {
    "methods": [
     {
      "verb": "GET"
     },
     {
      "verb": "PUT"
     }
    ],
    "tags": [
     "x",
     "y"
    ],
    "tier": "gold"
   },
   "id": "a",
   "links": [],
   "parent": "g",
   "plane": "p1",
   "title": "a",
   "type": "svc"
  },
  {
   "body": "",
   "fields": {
    "methods": [
     {
      "verb": "GET"
     }
    ],
    "tags": [
     "z"
    ],
    "tier": "silver"
   },
   "id": "b",
   "links": [],
   "parent": null,
   "plane": "p2",
   "title": "b",
   "type": "queue"
  },
  {
   "body": "",
   "fields": {
    "methods": [
     {
      "verb": "DELETE"
     }
    ],
    "tags": [],
    "tier": "bronze"
   },
   "id": "c",
   "links": [],
   "parent": "a",
   "plane": "p2",
   "title": "c",
   "type": "cache"
  },
  {
   "body": "",
   "fields": {
    "tier": "gold"
   },
   "id": "d",
   "links": [],
   "parent": null,
   "plane": "p1",
   "title": "d",
   "type": "other"
  },
  {
   "body": "",
   "fields": {},
   "id": "g",
   "links": [],
   "parent": null,
   "plane": null,
   "title": "g",
   "type": "group"
  },
  {
   "body": "",
   "fields": {
    "order": 1
   },
   "id": "p1",
   "links": [],
   "parent": null,
   "plane": null,
   "title": "p1",
   "type": "plane"
  },
  {
   "body": "",
   "fields": {
    "order": 2
   },
   "id": "p2",
   "links": [],
   "parent": null,
   "plane": null,
   "title": "p2",
   "type": "plane"
  },
  {
   "body": "",
   "fields": {
    "applies_to": {
     "type": [
      "svc",
      "queue"
     ]
    },
    "check": {
     "require_fields": [
      "owner"
     ]
    },
    "statement": "s"
   },
   "id": "r1",
   "links": [],
   "parent": null,
   "plane": null,
   "title": "r1",
   "type": "rule"
  },
  {
   "body": "",
   "fields": {
    "applies_to": {
     "plane": [
      "p2",
      "p9"
     ],
     "type": [
      "svc",
      "queue"
     ]
    },
    "check": {
     "require_fields": [
      "owner"
     ]
    },
    "statement": "s"
   },
   "id": "r2",
   "links": [],
   "parent": null,
   "plane": null,
   "title": "r2",
   "type": "rule"
  },
  {
   "body": "",
   "fields": {
    "applies_to": {
     "tier": [
      "gold",
      "silver"
     ]
    },
    "check": {
     "require_fields": [
      "owner"
     ]
    },
    "statement": "s"
   },
   "id": "r3",
   "links": [],
   "parent": null,
   "plane": null,
   "title": "r3",
   "type": "rule"
  },
  {
   "body": "",
   "fields": {
    "applies_to": {
     "methods[].verb": [
      "PUT",
      "DELETE"
     ]
    },
    "check": {
     "require_fields": [
      "owner"
     ]
    },
    "statement": "s"
   },
   "id": "r4",
   "links": [],
   "parent": null,
   "plane": null,
   "title": "r4",
   "type": "rule"
  },
  {
   "body": "",
   "fields": {
    "applies_to": {
     "tags[]": [
      "x",
      "z"
     ]
    },
    "check": {
     "require_fields": [
      "owner"
     ]
    },
    "statement": "s"
   },
   "id": "r5",
   "links": [],
   "parent": null,
   "plane": null,
   "title": "r5",
   "type": "rule"
  },
  {
   "body": "",
   "fields": {
    "applies_to": {
     "under": [
      "g",
      "a"
     ]
    },
    "check": {
     "require_fields": [
      "owner"
     ]
    },
    "statement": "s"
   },
   "id": "r6",
   "links": [],
   "parent": null,
   "plane": null,
   "title": "r6",
   "type": "rule"
  },
  {
   "body": "",
   "fields": {
    "applies_to": {
     "id": [
      "a",
      "d",
      "nope"
     ]
    },
    "check": {
     "require_fields": [
      "owner"
     ]
    },
    "statement": "s"
   },
   "id": "r7",
   "links": [],
   "parent": null,
   "plane": null,
   "title": "r7",
   "type": "rule"
  },
  {
   "body": "",
   "fields": {
    "applies_to": {
     "type": []
    },
    "check": {
     "require_fields": [
      "owner"
     ]
    },
    "statement": "s"
   },
   "id": "r8",
   "links": [],
   "parent": null,
   "plane": null,
   "title": "r8",
   "type": "rule"
  },
  {
   "body": "",
   "fields": {
    "applies_to": {
     "type": "svc"
    },
    "check": {
     "require_fields": [
      "owner"
     ]
    },
    "statement": "s"
   },
   "id": "r9",
   "links": [],
   "parent": null,
   "plane": null,
   "title": "r9",
   "type": "rule"
  }
 ],
 "results": [
  {
   "node": "a",
   "rule": "r1",
   "severity": "warn",
   "status": "fail"
  },
  {
   "node": "a",
   "rule": "r3",
   "severity": "warn",
   "status": "fail"
  },
  {
   "node": "a",
   "rule": "r4",
   "severity": "warn",
   "status": "fail"
  },
  {
   "node": "a",
   "rule": "r5",
   "severity": "warn",
   "status": "fail"
  },
  {
   "node": "a",
   "rule": "r6",
   "severity": "warn",
   "status": "fail"
  },
  {
   "node": "a",
   "rule": "r7",
   "severity": "warn",
   "status": "fail"
  },
  {
   "node": "a",
   "rule": "r9",
   "severity": "warn",
   "status": "fail"
  },
  {
   "node": "b",
   "rule": "r1",
   "severity": "warn",
   "status": "fail"
  },
  {
   "node": "b",
   "rule": "r2",
   "severity": "warn",
   "status": "fail"
  },
  {
   "node": "b",
   "rule": "r3",
   "severity": "warn",
   "status": "fail"
  },
  {
   "node": "b",
   "rule": "r5",
   "severity": "warn",
   "status": "fail"
  },
  {
   "node": "c",
   "rule": "r4",
   "severity": "warn",
   "status": "fail"
  },
  {
   "node": "c",
   "rule": "r6",
   "severity": "warn",
   "status": "fail"
  },
  {
   "node": "d",
   "rule": "r3",
   "severity": "warn",
   "status": "fail"
  },
  {
   "node": "d",
   "rule": "r7",
   "severity": "warn",
   "status": "fail"
  }
 ],
 "structure": {
  "errors": [],
  "warnings": []
 }
}