# Expressions and Validation

Source: https://help.zira.us/docs/data-sources/create-and-edit/expressions-and-validation
Summary: Use expressions, formulas, and validation rules to calculate values, enforce quality checks, and guide more advanced data-source behavior.
Updated: 2026-04-26

Use expressions and validation when the data source needs to do more than simple data entry.

This is an advanced setup area. It is useful when you want to:

- calculate one field from other values
- normalize or transform incoming values
- reject invalid readings
- reference values from connected data sources

## When to use expressions

Use expressions when a value should be derived instead of entered directly.

Common examples:

- calculate totals from several numeric fields
- convert a raw number into another unit or scale
- populate a field based on another field
- reuse values from connected data sources

## Prepare the data source first

Before you write expressions:

1. Create the main fields you need.
2. Add any connected data sources under **More settings** if the logic depends on other sources.
3. Save the data source so the schema is stable.

This makes expressions easier to test and maintain.

## Add expression-based logic

1. Open the data-source editor.
2. Add or open the field you want to calculate.
3. Enter the expression or formula in the field configuration.
4. Save the data source.

If the expression changes existing reading behavior, Zira can ask whether previous readings should be recalculated.

## Use validation rules

Use validation when a reading should be accepted only if it meets a rule.

Common validation checks include:

- minimum value
- maximum value
- minimum length
- maximum length
- required values
- allowed values

Use these rules when you want to prevent low-quality readings from entering the workflow.

## Write expressions carefully

Keep expressions easier to maintain by following a few rules:

- start with simple formulas before building larger ones
- use clear field structure and labels so the logic is easier to follow later
- add connected data sources only when they are really needed
- review recalculation prompts carefully on active data sources

If a formula becomes difficult to read, split the logic across more than one field instead of forcing everything into a single expression.

## What to expect after saving

After you save:

- derived values can be calculated as readings move through normalization
- validation rules can reject or fail readings that do not match the configured limits
- existing readings may be recalculated if you confirm that step during save

## Get help from AI Assistance

AI Assistance can help you think through:

- which fields to add first
- how to structure a calculated field
- what validation rules fit a use case
- how to break a complex formula into smaller steps

When you ask, describe:

- the fields you already have
- the value you want to calculate
- any ranges or limits you need to enforce

## Read next

- [Fields and Structure](/docs/data-sources/create-and-edit/fields-and-structure) - Organize fields before adding expressions.
- [Advanced Settings](/docs/data-sources/create-and-edit/advanced-settings) - Connect other data sources and save safely.
