Custom validations by queries

It is possible to define custom validations which can be triggered by Traceability → Validation → Validation Queries.
The results of validation queries are shown as issues (warning, error or info) in the YT Issues view and as decorations of the artifacts. There are quick fixes to navigate to the artifact or the query.

Syntax of validation queries

Validation queries are mostly Queries which are described in The YT query language chapter with some special adjustments:

validation query … collect(… as Artifact, … as ErrorMessage)

Each validation query is identified by the keyword validation and has at least one column Artifact with a reference to the artifact and one column ErrorMessage with the issue text. A third column Severity for values in „Error”, „Warning” or „Info” is optional.

Example for a validation query

Validation queries can use other queries to calculate the desired result and can be executed like other queries also. in this example we calculate all system requirements which are not refinements of stakeholder requirements. The main purpose of the validation query is the definition of the artifacts which are an issue and reducing the default severity of error to warning.

// Complex calculation of business specific definitions
query "linked System requirements" source (allTraceLinks('Stakeholder requirements --> System requirements')).collect (ArtifactB as Artifact)
query "all System requirements" source (allArtifacts('System requirements')).collect (it as Artifact)
// Special validation query to produce warnings
validation query "not required word" source (reduceBy(q('all System requirements'),q('linked System requirements')))
.collect (
  column("Artifact") as Artifact,
  "System requirements should be refinements" as ErrorMessage,
  "Warning" as Severity)