Skip to main content

Validation

Validation means checking whether entered data satisfies the required rules. This is especially relevant in EditViews, where the user is actively changing or creating records.

ADITO already provides built-in validation for some common cases. For example, EntityFields marked as mandatory are automatically treated as invalid while they are empty. This has two visible effects:

  • the Save button is disabled, and
  • the message Required value is missing is displayed.

Validation levels

In addition to these automatic validations, ADITO supports custom validation through onValidation processes. These processes are available on two levels:

  1. At Entity level, for validations that depend on multiple fields or on the overall state of the Entity
  2. At EntityField level, for validations that apply to one specific field

At Entity level, onValidation is triggered whenever any EntityField is entered. At EntityField level, it is triggered when the corresponding field loses focus.

Result handling

In both cases, the validation logic can be implemented as required. ADITO evaluates the process result as follows:

  • The input is treated as valid if the result is true, for example result.string(true);, or if the process returns no result.
  • The input is treated as invalid if the result is false, for example result.string(false);. In that case, saving is blocked.
  • The input is also treated as invalid if the result is a text, for example result.string("The end date must not be equal to or earlier than the start date.");. This is the most common pattern because the returned message is shown next to the disabled Save button.