Data constraints define the type of value that a form attribute may take, and may also restrict the actual values. Data constraints are defined separately, then used/referenced on attributes within form configuration. Attributes with an associated restricted value data constraint would typically present (i.e. dependant on the widget) as a select list for the user to select a value from in the UI.
- XML structure
- dataConstraint Element
- value Element
- Form usage
XML structure
Data constraints are defined using the following XML structure:
<dataConstraints>
<dataConstraint name="dateOnly" type="dateonly"/>
<dataConstraint name="gender" type="string" restrict="true">
<description>Gender</description>
<value code="M" textKey="constraintType.gender.M"/>
<value code="F" textKey="constraintType.gender.F"/>
<value code="X" textKey="constraintType.gender.X" active="false"/>
...
</dataConstraint>
...
</dataConstraints>
dataConstraint Element
| Attribute | Details | Description |
|---|---|---|
| name | required; string | The name of the data constraint |
| type | required; string | The type of values the data constraint relates to. Supported values are: binary – a binary chunk of data dateonly – a date-only value i.e. day, month and year datetime – a date time value date decimal – an exact precision decimal number double – a double-precision, floating-point number long – a numeric value string – an alphanumeric value timeonly – a time value i.e. hour, minute, seconds and milliseconds yesno – Y(es) or N(o) value |
| restrict | optional; booleandefault: false | Indicates whether the data constraint has a list of restricted values. If true, the data constraint must be one of the specified values. |
| sortBy | optional; stringdefault: text | How the values are sorted. Supported values are: code – alphabetical based on the code values ordinal – in the order they are defined within the data constraint text – alphabetical based on the resolved textual value of the values |
| order | optional; stringdefault: asc | The order of the values. Supported values are: asc – ascending: lowest to highest desc – descending: highest to lowest |
| allowMultiple | optional; booleandefault: false | When true the dataConstraint allows multiple values, typically stored as a comma-separated list of values. |
| extends | optional; string | The name of the data constraint that this one extends. If set this data constraint inherits the values from the one it’s extending but can override values making them inactive if it doesn’t want to include them. |
| mergeStrategy | optionaldefault: append | Determines how the constraint will be merged in relation to other occurrences of this named data constraint from other modules within the application. Supported values are: append – honours the existing data constraint and adds the values defined to the end of the listreplace – ignores the existing data constraint and overwrites it with this one prepend – as per append, but adds the values to the beginning of the existing data constraint’s values |
value Element
| Attribute | Details | Description |
|---|---|---|
| code | required; string | Code that is unique within the dataConstraint that is used to identify a value. |
| textKey | required; string | The text key which defines the textual representation of the data constraint value. |
| order | optional; integerdefault: 0 | Used to override/customise the order for the data constraint value within the list of values. If non-zero, the sortBy and order values specified on the data constraint are ignored and the constraint value is ordered compared to other ordered values of the same sign before (+ve) or after (-ve) the rest of the values based on the default ordering defined on the parent constraint. The smaller +ve the closer to the top, the bigger the -ve the closer to the bottom e.g. 1, 2, 5 … -1, -3, -10 |
| active | optional; booleandefault: true | When false the constraint value is inactive and is ignored. |
Form usage
Once a data constraint is defined as outlined in the sections above, using it for an attribute within the form configuration is a simple matter of referencing it from the attribute configuration as per the following examples:
<attribute attribute="DateOfBirth" dataConstraint="dateOnly" textKeyPrefix="individual.dob"/>
<attribute attribute="Gender" dataConstraint="gender" mandatory="true" textKeyPrefix="individual.gender"/>
0

