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
Savebutton is disabled, and - the message
Required value is missingis displayed.
Validation levels
In addition to these automatic validations, ADITO supports custom validation through onValidation processes. These processes are available on two levels:
- At Entity level, for validations that depend on multiple fields or on the overall state of the Entity
- 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 process returns no result,
null, an empty value, or only whitespace, for exampleresult.string("");,result.string(null);, orresult.string(" ");. - The input is treated as invalid if the result contains any text, for example
result.string("The end date must not be equal to or earlier than the start date.");. Returning a clear and helpful validation message is best practice, because this text is shown to the user. - Boolean values such as
trueorfalseare also treated as invalid.