Skip to content

Filtering vs Validation

Filters and validations look similar but serve completely different purposes. Mixing them up is one of the most common sources of rules that silently produce wrong results.


The hard separation

Filter Validation
Purpose Select scope Judge correctness
Question Which objects does this rule apply to? Is this value correct?
Output A shaped dataset Pass or fail per element
May exclude data? Yes — intentionally narrow scope Never — must see all relevant data
Reports errors? No Yes

Filters select. Validators judge.

A filter decides which elements the rule applies to. It is not allowed to have an opinion about whether data is correct.

A validator decides whether a specific value passes or fails. It never selects or excludes elements — it only evaluates what the filter gave it.

Example: checking that Mark is filled

Filter (selects all FamilyInstances, exposes mark):

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

Validator (judges whether mark has a value):

valueToValidate: mark
validator: Not empty

The filter does not check whether mark is empty. The validator does not decide which elements to include. Each part does exactly one thing.


The trap: filtering out bad data

Imagine you want to check that all doors with Assembly Code 32.31 have a Mark.

A tempting but wrong approach:

$[type = "FamilyInstance" and values.mark != null]

This filter excludes instances without a mark — the exact elements the rule should be catching.

The validator will always pass because only elements with a mark ever reach it.

If you filter out incorrect data, you have already lost.

The correct approach: filter on scope (category, type, level), not on the value you want to validate.

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

Now elements with a missing mark are included in the filter output — and the validator can catch them.


What filters are allowed to do

Filters may exclude elements based on scope — things that define which elements this rule applies to:

  • Object type (type = "FamilyInstance")
  • Category (values.category.name = "Doors")
  • Assembly Code prefix
  • Whether the family is editable
  • Level or phase

Filters must never exclude elements based on the value being validated.


Why this matters in practice

A rule that filters out invalid data will:

  • always show 0 errors
  • give a false sense of data quality
  • silently miss the exact problems it was meant to catch

This is worse than having no rule at all — because it gives false confidence.


Summary

Filters define scope. Validators define correctness. Never let the filter do the validator's job.