Validations
Validations are applied when data is saved in the database. When data does not meet the validation rules, the data are not saved and an error message appears on the page. Developers using the Application Engine have access to pre-built helpers that can be used instead of building their own filters.
Simple validations
While defining a class with fields in the studio, some properties activate validations automatically.
- defining a data type results in an automatic check that the data confirms the data type. Entering a non-numerical entry in a 'whole number" field will result in an error. Entering an invalid email address in an 'email address' field will result in an error also.
- defining a field as a key field results in an automatic check that the values are unique.
- defining a field as a login name does the same.
- setting the property unique does the same.
- setting the property maximum length results in a check of the number of characters.
Extended validations
You can also add extended validations to classes. Whenever data is updated in the class, this validation will be ran. This can be done in the blueprint by clicking the "Add validation"-button under the "Validations" tab in the class view. Here, a filter can be set. Records that do not match the filter will not pass the validation. Regular expressions can be used when the "matches" operation is chosen. To learn more about constructing filters, see the filters page.
Helpers can be used in addition to filters. Just set the helper type, after which the helper parameters can be set by clicking on "Edit parameters". See the next section for the available validation helpers. Lastly, the error message that will be shown when the validation fails can be set under the tab Messages, see image below for an example with a filter in the backstage. When both a filter and a helper are used, only records that match the filter will be validated using the helper.
see image below for in the application
Validation helpers
The validation helpers that offered by Application Engine are the following:
- Deduplication
Checks if a record already exists based on a specified filter.
- JAVA plugin helper
A class validation implemented in a JAVA class file. This option is not available yet for external developers. CrossmarX can program the calculations in the mean time. If you want to develop the calculation your self, please use Velocity.
- Only one true
Checks whether only one record in a group has a value 'yes'.
- Overlapping range
Determines wether a given range, intersects with an existing range in the database. It is often used in clazzes representing calendar data. For example consider a class describing car reservations. A new car reservation may not intersect or overlap an existing reservation of the same car.
- Required fields
Checks if fields have values before they are saved. The default behaviour is that at least one of the specified fields has a value. With the parameter "Mode" you can override this to set the values for all fields as required (set the value to "ALL").
e.g.: First name or Initials
e.g.: First name and Last name
- Script
Use this helper to implement a validation using a script.
- Unique fields
Ensures that a combination of field values is unique.
- Velocity
You can write your own class validation and integrate it in the Application Engine.