Expression validation rule – accept a value only if a condition holds¶
An expression validation rule checks a new value of a field with a condition. A value for which the condition is not true is not accepted. This page describes its settings and behaviour. It is intended for administrators who configure business rules.
1. At a glance¶
| Purpose | Accepts a value only if a condition returns true |
| Typical use | Value ranges (a discount between 0 and 30), formats (a postcode with five digits), relations between fields (end date not before start date) |
| Related | List validation rule, Lookup validation rule, Required for save rule |
2. Settings¶
| Setting | Meaning | Default / required |
|---|---|---|
| "Field" | The field whose values are checked | required |
| "Validation" | A condition (an expression with the result true or false). "The value entered in the field is only accepted if this expression evaluates to true." | required |
| "Disabled" | The rule does not apply | off |
Plus "Display Name", "Description" and "Tags" (see Business rules).
The condition is evaluated against the record after the new value was put into the field. It reads the checked value through a normal reference to the field.
3. Behaviour¶
- The value is checked when it is set – by a user, an action, a rule or the REST API – not at the save.
- Only the result true accepts the value. False, an empty result or any other value rejects it.
- A rejected value is not kept. The field gets its previous value back, and the rules that would have reacted to the change do not run. The user sees no message; the field simply shows the previous value again. If the previous value no longer satisfies the rules either, the field is marked as invalid and the record cannot be saved until an accepted value is entered.
- Empty values are always accepted. To demand a value, add a required for save rule. A date of 1 January 1753 or earlier – the stored form of an empty date – counts as empty as well and is therefore always accepted.
- Several validation rules on one field are alternatives. Expression, list and lookup validation rules of the same field are combined with "or": the value is accepted as soon as one of them accepts it.
- If the selected expression no longer exists, the rule accepts nothing. If it is the only validation rule of the field, every non-empty value is rejected until you fix the rule.
4. Examples¶
Range. Entity Offer, "Field" = Discount, "Validation" = Discount ≥ 0 and Discount ≤ 30. Entering 25 is accepted; entering 40 restores the previous value.
Order of dates. Entity Project, "Field" = End date, "Validation" = End date ≥ Start date. With the start date 1 March, the end date 15 February is rejected.
5. Limitations¶
- A value is checked only when it is set. If the rule refers to other fields, a later change of those fields does not check the value again. In the example above, moving the start date to 1 April leaves the end date 15 March in place. Add the same check for the other field if both directions matter.
- Values that existed before the rule was created are not checked.
- Rejections are silent. If users need an explanation, show a hint in the form, for example with the label or placeholder of the input field.