Skip to content

First rule explained

This page walks through a complete DAQS rule step by step and explains why each part exists.

The goal is not to teach JSONata syntax — the goal is to understand how DAQS rules are structured and read.


The rule we will explain

This is a deliberately simple rule:

Every FamilyInstance must have a Mark parameter.

{
  "filter": {
    "type": "queryFilter",
    "properties": [
      {
        "name": "Query",
        "value": "(\n  $[type = \"FamilyInstance\"].{\n    \"id\": id,\n    \"type\": type,\n    \"name\": name,\n    \"mark\": values.mark\n  }\n)"
      }
    ]
  },
  "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"
            }
          ]
        }
      }
    ]
  }
}

How to read a DAQS rule (mental model)

Every DAQS rule has two main parts:

  1. FilterWhich objects does this rule apply to?
  2. ValidationWhat must be true for each of those objects?

Always read rules in that order.


Part 1 — The filter (scope definition)

$[type = "FamilyInstance"].{
  "id": id,
  "type": type,
  "name": name,
  "mark": values.mark
}

What this does

This filter:

  • Selects all FamilyInstance objects
  • Shapes the output into a predictable structure
  • Extracts only the data needed for validation

Important: the filter does not judge correctness

The filter does not decide whether mark is valid or missing.

It only answers:

“For which objects do we want to check something?”


Why the filter output shape matters

The filter returns objects like this:

{
  "id": 615432,
  "type": "FamilyInstance",
  "name": "Door 1018x2387",
  "mark": "D-01"
}

Or, if the parameter is missing:

{
  "id": 615433,
  "type": "FamilyInstance",
  "name": "Door 1018x2387",
  "mark": null
}

This output shape is what the validation works on.

If the filter output is wrong or incomplete, the validation can never behave correctly.


Part 2 — The validation (judging correctness)

What value is being validated

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

This tells DAQS:

“From each filtered object, take the field called mark.”

It directly corresponds to the filter output.


What rule is applied

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

This means:

“The mark property must exist.”

Important:

  • This checks existence, not content
  • An empty or incorrect value is a different rule

What happens during execution

For each filtered object:

  1. DAQS reads mark
  2. DAQS checks whether the property exists
  3. If it does not exist → the rule fails for that object
  4. If it exists → the rule passes for that object

Each failure is reported per instance.


What this rule does not do (by design)

This rule does not:

  • Check whether mark is empty
  • Check formatting
  • Check uniqueness
  • Check type vs instance ownership

Those are separate rules.

DAQS rules should be:

Small, focused, and explicit


Why this rule is a good first example

This rule demonstrates:

  • Clear scope (FamilyInstance)
  • Clean filter output
  • Simple validation logic
  • No hidden assumptions
  • No advanced patterns

It is easy to:

  • Read
  • Debug
  • Extend
  • Review

Rule-reading checklist (use this every time)

When reading or writing a rule, always ask:

  1. What objects are filtered?
  2. What data is extracted?
  3. What exact condition is validated?
  4. What happens when data is missing?

If you cannot answer one of these, the rule needs work.


Key takeaway

Filters select. Validations judge. Output shape connects them.

Once this clicks, every other DAQS rule becomes easier to understand.