Unify Applications
Logo
Form Validation and Visibility

Form Validation and Visibility

Logo

6 mins READ

Configure field validation and conditional field visibility directly in the builder — without writing event handler code. This page is the how-to: it walks through the builder settings on each field. For the methods (validateForm, submitForm), the {{ form1.errors }} state and form events, see the full reference in Form Validation, Methods & Events.

unify-applications-form-validation-and-visibility-01-field-validation-settings.png
unify-applications-form-validation-and-visibility-01-field-validation-settings.png

Where the Settings Are

Select a field in the Form block's Fields editor. Each field has a Validation section (Is optional and Validity conditions) and a Visibility condition under Appearance. These settings are per field, not on the form as a whole.

Making a Field Required

Every field starts optional. To make it required, open Validation and turn Is optional off. The field then blocks submission until it has a value.

  • Is optional is a plain on/off toggle — it cannot follow a condition. For a conditionally required field, use one of the patterns below.

  • Checkbox (Boolean) and Switch fields have no Is optional toggle. Add a Validity condition (for example, Equals to true) to require them.

  • Array, Object and Pin Input fields don't show Is optional either.

Validity Conditions

For any check beyond "required" — formats, ranges, cross-field comparisons — add rules under Validation → Validity conditions.

  1. Add a rule.

  2. Build its condition in the visual AND/OR condition builder: pick an operator (for example, Match regex, Greater than or Equals to) and the value to compare against.

  3. Enter the error message to show under the field while the rule fails.

A field can carry several rules; each shows its own message while it fails, and all must pass for the field to be valid. To compare against another field, reference it with {{ form1.data.<fieldKey> }} — for example, a rule on confirmPassword that it equals {{ form1.data.password }}, with the message "Passwords do not match."

For the full list of operators each field type offers, see Form Validation, Methods & Events.

When Errors Appear

Errors appear under each field after the first submit (or validateForm call) and update live after that. No errors show while the user first fills the form in. Resetting the form returns it to this silent state.

Warning: When a field is hidden by its visibility condition, its validation rules do not run and it doesn't block submission. A disabled field's rules are skipped too; a read-only field's rules still run.

Visibility Conditions

Show or hide a field based on a condition. Open the field and set Appearance → Visibility. When the condition is false the field is hidden, its value is removed from the form's data and the submit payload, and its validation rules are skipped. When it is shown again, it comes back with its default value, not the user's earlier entry.

Reference other fields with {{ form1.data.<fieldKey> }}. Examples:

  • Show "GST Number" only when country is India: {{ form1.data.country == "IN" }}

  • Show "Other reason" only when "Other" is chosen: {{ form1.data.cancellationReason == "other" }}

  • Hide a field until a prior field has a value: {{ !!form1.data.firstName }}

Showing Fields to Certain Users Only

To restrict a field to certain users, use the field's Permissions rule rather than a visibility condition. A user who doesn't meet the rule has the field removed from the form, or shown read-only if "when no permission" is set to read-only.

Conditionally Required Fields

Because Is optional can't follow a condition, use one of these patterns. The numbering matches Form Validation, Methods & Events. The examples use a GST Number field (key gstNumber) that is required only when Country (key country) is India.

Pattern 1: Validity Condition (field stays visible)

  1. Leave Is optional on and add a Validity condition on the GST Number field.

  2. Build one rule group with OR between two conditions: {{ form1.data.country }} Does not equal IN, and {{ form1.data.gstNumber }} Is present. The rule passes when the country isn't India or the field has a value.

  3. Set the error message, for example "GST Number is required for India."

Pattern 2: Visibility + Required (field appears only when relevant)

  1. Turn Is optional off on the GST Number field.

  2. Set its Visibility condition to {{ form1.data.country == "IN" }}.

  3. The field appears — and requires a value — only for that case. When hidden, it sends no data and its required check is skipped.