# Conditions and operators

<PageBadges />

Conditions are used in `visible_conditions`, `required_conditions`, and `read_only_conditions`.
They reference other fields and evaluate to true or false.

## Condition shape

```json
{
  "field_id": "age",
  "operator": "greater_or_equal_than",
  "value": 18
}
```

You can combine conditions with `and` or `or`:

```json
{
  "and": [
    { "field_id": "country", "operator": "equal_to", "value": "us" },
    { "field_id": "age", "operator": "greater_or_equal_than", "value": 18 }
  ]
}
```

## Operators

| Operator                | Meaning                      |
| ----------------------- | ---------------------------- |
| `equal_to`              | Equals the provided value    |
| `not_equal_to`          | Not equal to the value       |
| `greater_than`          | Greater than the value       |
| `less_than`             | Less than the value          |
| `greater_or_equal_than` | Greater than or equal to     |
| `less_or_equal_than`    | Less than or equal to        |
| `contains`              | Array contains the value     |
| `starts_with`           | String starts with the value |
| `is_empty`              | Value is empty or null       |
| `is_not_empty`          | Value is not empty           |

### Operator support by field type

Operators are validated against the referenced field type. For example:

- Text fields support `contains` and `starts_with`
- Numeric/date fields support comparison operators
- Choice fields support `equal_to` and `contains` (multi-choice)

If an operator is invalid for the referenced field, validation will fail.

## Field references

`field_id` should point to the field `key`. `data_name` is accepted as a fallback, but `key` is
recommended because it never changes when labels change.
