Entity Field Validations

Add validations to Entity Fields. Multiple validation rules may be specified for an Entity Field. To add validations to an Entity Field:

  1. Click the Field Name in the Field list and select the required validations from the Validation > Validations property.

  2. Configure the validation properties as per the validation types given below in the List of Validations.

  3. Click Save to save the changes and generate the UI.

List of Validations

Validation Type

Description

Required

Enforces a Required or Not-Null constraint on the property. See the Email field in XLib.Samples.Todo > Employee.

Unique

Used to apply unique validation. Composite keys for the unique constraint may be selected in the Composite Keys property. See the Email field in XLib.Samples.Todo > Employee.

Range

Available for numeric properties only. Requires a Start Value and End Value to be provided for the Property. See the Completion % field in XLib.Samples.Todo > Task Entity.

Pattern

Requires a regex pattern to be provided for validation in the Pattern property. Also, set the pattern validation error message in the Localized Pattern Message property.
Example pattern for email validation:
(|^(([^<>()\\[\\]\\\\.,;:\\s@\"]+(\\.[^<>()\\[\\]\\\\.,;:\\s@\"]+)*)|(\".+\"))@((\\[[0-9]{1,3}\\.[0-9]{1,3}\\.[0-9]{1,3}\\.[0-9]{1,3}])|(([a-zA-Z\\-0-9]+\\.)+[a-zA-Z]{2,})))$.
See Email field in XLib.Samples.Todo > Employee.

Length

Available for text properties only. Requires a Minimum length and Maximum length to be provided for the Property. See the Task Name field in XLib.Samples.Todo > Task Entity.

Custom

JavaScript for validation is to be provided in the Custom Validation Script. Custom validation error message to be provided in the Localized Custom Validation Message property.
Example: See the Start Time field in the XLib.Samples.Todo > Task Entity.

From List

This validation creates a dropdown on the UI for the field. This validation provides the option of 3 types of option loaders:

  1. Static: Select Options Loader Type as Static. Provide a JSON array of the options in the Selection Options field. Example: [ { label: "High", value: 3 }, { label: "Medium", value: 2 }, { label: "Low", value: 1 } ]. See the Priority field in XLib.Samples.Todo > Task Entity.

  2. API: Select Options Loader Type as API. Configure using Entity API, Label Field, and Value Field.

  3. Script: (Only for Parent(1) fields): Provide the script in Options Loader Script. Available variables:

    • session: The user session

    • source: The entity object being modified

    • utils: Utility object