See Agility CMS in action. Watch a product demo
Conditional & Cross-Field Validation
Agility content models support built-in field validation — required, length, and format constraints — plus regular-expression validation on a single field via the model's Advanced tab for precise format rules (emails, phone numbers, postal/zip codes, custom patterns). For logic that depends on another field's value — for example, "if Status is Published, then a Publish Date is required," or "End Date must be after Start Date" — validation is implemented with a custom field app: a developer-built field extension that has access to the item's values and enforces the conditional/cross-field rule. Agility does not use server-side "validation scripts"; per-field formatting is handled by regex, and anything beyond a single field is handled by a custom field app.
Built-in, per-field validation
Standard model field settings cover the common cases:
- Required — the field must have a value.
- Length — minimum/maximum length constraints.
- Format via regex — on the field's Advanced tab, add a regular-expression pattern plus a custom validation message; the field then only accepts values matching the pattern. Useful for emails, phone numbers, URLs, postal codes, SKUs, and other structured formats.
These rules evaluate a single field in isolation and do not reference other fields.
Conditional and cross-field validation (depends on another field)
When a rule must consider more than one field, it is implemented with a custom field app — a custom field/UI extension you build and register on the content model. Because the app renders a field within the editor and has access to the item's other field values, it can enforce conditional and cross-field rules and surface a validation message to the editor.
Typical cross-field / conditional patterns a custom field app can enforce:
- Conditional requirement: Field B is required only when Field A has a certain value (e.g. require Redirect URL only when Type = External).
- Comparison across fields: End Date must be after Start Date; Discount Price must be less than Price.
- Mutually exclusive / dependent fields: exactly one of two fields must be filled; or Field C is forbidden when Field D is set.
- Aggregate/conditional constraints: total of several numeric fields must not exceed a cap.
A worked custom-field-app example (e.g. End Date > Start Date) isn't published here; contact Agility for current sample code and guidance.
Choosing the right tool
| Need | Use |
|---|---|
| Single field required / length | Built-in field settings |
| Single field must match a format | Regex validation (Advanced tab) |
| Rule depends on another field's value | Custom field app |
| Rule depends on external data/service | Custom field app (calling your service from the app) |
Shared responsibilities
| Area | Agility | Implementation partner / customer |
|---|---|---|
| Built-in + regex validation | ✅ Provided in the content model UI | ✅ Configures patterns and messages |
| Cross-field / conditional validation | ✅ Provides the custom field app framework | ✅ Builds, tests, and maintains the custom field app |
| Editor experience of errors | ✅ Surfaces validation failures in the editor | ✅ Writes clear, actionable validation messages |
| Governance | — | ✅ Decides which rules are enforced and documents them for editors |