Constraints (TMF Tools) - Xyna-Factory/xyna GitHub Wiki

When using TMF Tools, Constraints are a tool for validating TMF Services.

Constraints are formulaic expressions referring to values of the TMF 640 service JSON that have to evaluate to "true" for the validation of the constraint to succeed. Each constraint consists of three parts:

  1. conditional expression: When will this constraint be checked?
  2. rule expression: The actual constraint that creates the validation result
  3. json paths: JsonPath expressions that point to the values to be used inside the conditional and the rule expression. They are evaluated against the service JSON document.

Combined this allows for validation of arbitrary consistency requirements for field values, count of fields, etc.

Additional features:

  • dependencies (list of the names of other constraints): A constraint is only checked if all of its dependencies have been resolved successfully
  • context: A constraint can be assigned to different contexts. It will only be checked if the currently active context (input of the validation workflow) is included in the list of contexts of the constraint (or it has no contexts). you can provide contexts of different types. Example: Assigning a constraint the context {type=Weekday, value=Monday}, it will only be checked on mondays, assuming you provide the correct day of the week.

Syntax of conditional and rule expressions are specified in the documentation field of expression member variable in the Data Type xfmg.tmf.validation.JSONPathExpressionV2, i.e. open the Xyna Process Modeller and look at the documentation there. Example: LEN(EVAL($0))>=2 OR EVAL($1)=="value"

Syntax of supported json path expressions can be found here: JSON-Path

Constraints are specified in the service specification (TMF633), or as an Annotation of your Xyna service data type if you use the "Create Service" Tool.