Advanced validation script structure

The advanced script structure contains up to three sections, which are all contained in a rule.

Copy code

rule {
	given {
	}
	when {   
	}
	then {
	}
}

Given-section

You can use this optional section to define variables that you can re-use in the rest of the script. Variables can make the rest of the validation script more readable. It allows you to separate data creation from the actual constraint-checking validation logic.

Each line of the given-section contains a variable name, an equal sign and an asset property. More info: Asset model.

When-section

You can use this optional section if certain conditions have to be met before the rule is executed. If you do not use this section, the validation logic is applied to all assets.

If an asset does not meet these conditions, the validation logic is not executed and the outcome of the rule is valid.

If the conditions are met, the validation logic is executed. The outcome of the rule will then depend on the actual validation logic in the then-section.

Each line of the when-section typically contains:

  1. A validation function. More info: Validation functions.
  2. An attribute from the given-section, an asset property or a constant value that you entered in the script.

Then-section

The then-section contains the pure validation logic. More information: Validation logic.