context.has

Require the text to mention values supplied by the run's context (a branch, a ticket, a version).

Science officer: Fascinating claim. Source?

needs context What to pass

Quick reference

Examples

context.has

Require the section body to contain the string value of context.values.<key>, supplied via --context. A run without that key could not check the document (missing-context-value); a trailing ? (context.has=packageVersion?) makes that a note and the rule skips.

A section that states the context version passes

contract.mdv.md
<!-- mdv: section context.has=packageVersion -->
## Changelog
<!-- mdv: endsection -->
context.json
{ "values": { "packageVersion": "0.2.0" } }
document.md
## Changelog

Released 0.2.0.

✓ passes

A section that states a different version is flagged

contract.mdv.md
<!-- mdv: section context.has=packageVersion -->
## Changelog
<!-- mdv: endsection -->
context.json
{ "values": { "packageVersion": "0.2.0" } }
document.md
## Changelog

Released 0.1.9.

✗ context-value-missing error · line 3

A run with no context value could not check the document

contract.mdv.md
<!-- mdv: section context.has=packageVersion -->
## Changelog
<!-- mdv: endsection -->
document.md
## Changelog

Released 0.2.0.

✗ missing-context-value error

On this page