When developing a project, the accuracy of your data is very important. Using a reusable Business Object Base Type lets you extend native types with validation using limits, a predefined set of choices or patterns. Centralizing validation in a single location makes updates simple. It could also lets citizen developers use pre-determined field types developed by more technical team members. The Base Types library includes some Business Object Base Types for some commonly used types (e.g. Currency and Email Address).
Create a Base Type
To create a base type, create a normal business object on the Business Objects Page. When it opens on the Business Object Page, click the settings icon button in the upper right corner to open the settings dialog and change the Type field to a Base Type.
After you close the dialog, the Business Object page will look different:
The "Native Type" field defines what the underlying type is. It can be string, number, Date or boolean. After you select the native type, additional fields will be displayed based on type.
String Native Type Validations
String native type has four validation fields:
- Minimum Length
- Maximum Length
- Valid Values
In our example, we have added 4 options for a status in the system
If we wanted to validate a type using a regular expression we could use the expression field for the pattern and the Invalid Pattern Message field for the error message to display when the entry does not match the defined pattern. We can take a look at the EmailAddress base type from the Dynamic Components library to see how this is accomplished.
The pattern defined here will allow and unlimited number of character including letters, numbers and a few special characters (._%+-) followed by an @ sign which is followed by a domain consisting of letters and numbers, a period and an extension of letters between 2 and 4 characters in length. If the entered data does not match that pattern the invalid pattern message will be displayed.
Number Native Type Validations
Number native type has four validation fields:
- Minimum Value
- Maximum Value
- Fixed Decimal Places
- Display with thousands separator
The other native type that can be extended is a number. Creating a base type with a native type of number allows you to specify a minimum and maximum value for the field.