Validation
This content progresses from beginner to advanced Studio user knowledge.
Validation checks that a form's structure is compatible with its underlying openEHR template before the form is used in a live application. Understanding what validation does (and what it does not) is essential before activating any form.
What validation checks
When you run validation, Studio checks all visible fields on the current page against the following:
- Whether required fields (as defined by the openEHR template) have been addressed in the form
- Whether numeric fields fall within any defined range constraints
- Whether date fields conform to any defined format or range rules
- Whether any other field-level restrictions defined in the template are respected
What validation does not check
Validation does not check:
- Fields on pages other than the currently visible page
- Fields that are hidden by a dependency or conditional logic rule
- Fields that are not included in the form at all
- The full composition structure against the EHR Server template
Running validation
Validation is available in both Preview and Form playground:
- Open your form in Preview or Form playground.
- Enter data as a user would, or leave fields empty to test required-field behaviour.
- Click the Validate button in the toolbar.
If all visible fields on the current page are valid, no error notification appears.
If validation fails, an error notification appears. You can locate the fields in the editor easily, as they will have a red border and/or a "Required field" label visible. You can then make the necessary correction before running your validation again.
For multi-page forms, navigate to each page in sequence and validate each one individually.
Validation scope: Visible fields, hidden fields, and page-level rules
Visible fields only
Validation checks only the fields visible on the current page at the moment you click Validate. If a field is hidden, whether because it is on a different page, excluded from the form entirely, or hidden by a dependency, it is not validated.
Hidden fields and required status
A field hidden by a dependency is excluded from validation at that moment. This means a form can pass Studio validation even if the hidden field would ordinarily be required. If that field later becomes visible to a user (because the triggering condition is met), it becomes required at that point.
Page-level validation
Validation applies to one page at a time. There is no option to validate all pages in a single action. Navigate to each page and validate it individually.
How required fields are determined
Required status for each field is inherited from the openEHR template structure, not set manually in Studio.
The rules are as follows:
- A field is always required if it and all of its parent containers are required.
- A field is not required if it is required but its direct parent container is optional and the parent container contains no data (all sibling fields are empty).
- A field becomes required if it is required, its direct parent container is optional, but the parent container has at least one non-empty sibling field.
This behaviour reflects openEHR's multiplicity model, where the requirement of an element is conditional on whether its parent cluster has been entered.
Studio validation vs EHR Server validation
Studio validation and EHR Server validation are distinct processes. Understanding the difference prevents confusion when a form passes validation in Studio but a composition save then fails.
| Studio validation | EHR Server validation | |
|---|---|---|
| Triggered by | Click Validate in Preview or Form playground | Attempting to save a composition to the EHR Server |
| Checks | Visible fields on the current page | Full composition structure |
| Scope | Current page only | Entire template |
| Hidden fields | Excluded | May be required |
| Fields not in form | Not checked | May be required by template |
A form can pass Studio validation and still fail EHR Server validation if the template requires fields that are not present in the form or are on pages that have not been validated. If you consistently encounter EHR Server errors after passing Studio validation, review the template structure in ....
Frequently asked questions (FAQs)
How do I validate my form?
Click the Validate button in the Preview or Form playground toolbar. Studio checks all visible fields on the current page against the openEHR template structure.
Does validation check all pages at once?
No. Validation checks only the currently visible page. For multi-page forms, navigate to each page and validate it individually. There is no single-button option to validate all pages at once.
What does a validation error look like?
An error notification appears in the toolbar area. You can locate the fields in the editor. They will have a red border and/or a "Required field" label visible.
What happens if a required field is hidden by a dependency?
Hidden fields are excluded from validation. A form can pass Studio validation even if a hidden required field contains no data. If that field later becomes visible to a user, it becomes required at that point.
When exactly is a field required?
Required status is inherited from the openEHR template. A field is always required if it and all its parent containers are required. If a field is required but its direct parent container is optional and contains no data, the field is not required. If the parent container has any non-empty sibling fields, the required field becomes required.
What is the difference between Studio validation and EHR Server validation?
Studio validation checks visible fields on the current page against the template's multiplicity rules. EHR Server validation checks the full composition structure against the template. A form that passes Studio validation may still fail at the EHR Server if the template requires fields not present or not validated in the form.
Can I disable validation entirely in Form renderer?
Yes. Set validationDisabled: true in the EhrFormContext object passed to Form renderer. This disables all client-side validation in the rendered form.
Where is the validity indicator shown in Form builder?
Form validity is shown in Form builder as a green tick next to the Errors option in the bottom toolbar, giving an at-a-glance signal without needing to open Preview.