Skip to content

Validations

The validation part of a DAQS rule defines what must be true for each object returned by the filter. It has three required parts: a name, a valueToValidate query, and a validator.


The validation in the rule JSON

"validation": {
  "type": "validation",
  "name": "The instance must have a Mark parameter.",
  "properties": [
    {
      "name": "valueToValidate",
      "value": {
        "type": "querySelector",
        "properties": [
          {
            "name": "query",
            "value": "mark"
          }
        ]
      }
    },
    {
      "name": "Validator",
      "value": {
        "type": "value",
        "properties": [
          {
            "name": "value",
            "value": "propertyShouldExist:True"
          }
        ]
      }
    }
  ]
}

Name

The name field is shown to users in the Revit plugin when the validation fails. It is the first thing they read — it must communicate the problem clearly and concisely.

"name": "The instance must have a Mark parameter."

See Validation Name.


valueToValidate

The valueToValidate uses a querySelector to point at a specific field in the filter output.

{
  "type": "querySelector",
  "properties": [
    {
      "name": "query",
      "value": "mark"
    }
  ]
}

The query value is a JSONata expression evaluated against each object in the filter output. In most cases it is simply the field name — mark, assemblyCode, fireRating. It can also be a more complex expression if the value needs to be derived.

The query can only access what the filter returned. If the field is not in the filter output, the query returns null.

See Value to Validate.


Validator

The validator defines the condition that must be true for the rule to pass.

{
  "type": "value",
  "properties": [
    {
      "name": "value",
      "value": "propertyShouldExist:True"
    }
  ]
}

The value property combines the validator type and its configuration in a type:config format. Common examples:

Validator Value string
Property should exist propertyShouldExist:True
Property should not exist propertyShouldExist:False
Should not be null null:ShouldNotBeNull
String not empty string:NotEmpty
String matches regex string:Matches:^[A-Z]{2}-\d{3}$
Boolean is true bool:Is:true
List in list:In

For the full reference of validator types and their configuration, see All Validators — Quick Reference.


Collection of validations

A collection wraps multiple validations in a single rule. Each validation has its own name, valueToValidate, and validator. They all operate on the same filter output.

The rule fails for an element if any one of the validations in the collection fails. Each failing validation reports its own name and error message independently.