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

AttributeDetailsDescription
namerequired; stringThe name of the data constraint
typerequired; stringThe 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
restrictoptional; booleandefault: falseIndicates whether the data constraint has a list of restricted values. If true, the data constraint must be one of the specified values.
sortByoptional; stringdefault: textHow 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
orderoptional; stringdefault: ascThe order of the values.
Supported values are:
asc – ascending: lowest to highest
desc – descending: highest to lowest
allowMultipleoptional; booleandefault: falseWhen true the dataConstraint allows multiple values, typically stored as a comma-separated list of values.
extendsoptional; stringThe 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.
mergeStrategyoptionaldefault: appendDetermines 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

AttributeDetailsDescription
coderequired; stringCode that is unique within the dataConstraint that is used to identify a value.
textKeyrequired; stringThe text key which defines the textual representation of the data constraint value.
orderoptional; integerdefault: 0Used 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
activeoptional; booleandefault: trueWhen 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
0

Jump to Section