Skip to main content

Restrictions

A SimpleValueType is a ValueType that can be directly mapped to types in the code.

Common SimpleValueTypes include String, BigString, Integer, Double, Boolean, Timestamp and Date.

It is possible to create new SimpleValueTypes by adding them to a Component. Each SimpleValueType can have a protoType, which is another SimpleValueType. A SimpleValueType inherits the behavior of its prototype, except for the behavior that is defined by the Type itself.

<valueType name="DocumentName" type="elements::SimpleValueType">
<prototype name="String"/>
</valueType>

Types provided by web-styles (Knockout UI)​

TypeDescription
ShortA 16-bit signed integer value.
TextNormal text
HyperLinkShows a clickable link
FileLinkShows a clickable link for file download
BigStringEdit form shows a textarea
MarkupStringEdit form shows a richt text editor
PasswordUI shows *** instead of plaintext. Warning: underlying data is not protected.
IntegerInteger
BooleanBoolean
DoubleDouble
LongLong
ShortShort
DateEdit form shows a date picker
TimestampEdit form shows a date+time picker

Additional types​

In addition to the types that are provided by prime-core and Expanders, the standard-types expansion resourceExpansion Resource (ExpansionResource). A reusable resource bundle containing expanders and features that provide specific application capabilities, defined in the expansion settings and added to the classpath during expansion. also provides some additional types for more specific use-cases such as variable length strings, email addresses and more.

Restrictions​

After defining a new SimpleValueType, you can add restrictions on what values are valid for this specific type.

There are several restrictions that can be added to the model:

NotNull​

Add a NotNull restriction to a SimpleValueType to prevent the values from being undefined.

<valueType name="StrictBoolean" type="elements::SimpleValueType">
<prototype name="Boolean"/>
<restrictions>
<restriction type="elements::NotNull"/>
</restrictions>
</valueType>
tip

For Strings, this restriction also rejects empty Strings. If necessary, you can provide a custom undefined check for your own types:

Customizing Undefined Checks

StringLength​

You can limit the length of a String to a maximum length with the StringLength restriction. For standard Strings, this limit is set to 255 characters. By adding a restriction to your own SimpleValueType extending String, you can redefine this limit to be either smaller or larger than this limit.

It is also possible to define a minimum length if applicable. Combine this with the NotNull restriction to also prevent null values.

<valueType name="SmallString" type="elements::SimpleValueType">
<prototype name="String"/>
<restrictions>
<restriction type="elements::StringLength">
<minimum>2</minimum>
<maximum>16</maximum>
</restriction>
</restrictions>
</valueType>

StringPattern​

A StringPattern restriction provides a regex to check values against.

<valueType name="Email" type="elements::SimpleValueType">
<prototype name="String"/>
<restrictions>
<restriction type="elements::StringPattern">
<regex>[a-zA-Z0-9_.+-]+@[a-zA-Z0-9-]+\.[a-zA-Z0-9-.]+</regex>
</restriction>
</restrictions>
</valueType>

NumberBounds​

A NumberBounds restriction can be added to an Integer or Double to set a minimum and/or maximum value for a number.

<valueType name="Rating" type="elements::SimpleValueType">
<prototype name="Integer"/>
<restrictions>
<restriction type="elements::NumberBounds">
<minimum>1.0</minimum>
<maximum>10.0</maximum>
<includeMinimum>true</includeMinimum>
<includeMaximum>true</includeMaximum>
</restriction>
</restrictions>
</valueType>

Digits​

A Digits restriction limits the number of digits in the integer part and/or the fraction part of a number.

<valueType name="Price" type="elements::SimpleValueType">
<prototype name="Double"/>
<restrictions>
<restriction type="elements::Digits">
<fraction>2</fraction>
</restriction>
</restrictions>
</valueType>

Past/Future​

Dates can be limited with the Past or Future restriction, which forces a value to be in the past or the future.

<valueType name="BirthDay" type="elements::SimpleValueType">
<prototype name="Date"/>
<restrictions>
<restriction type="elements::Past"/>
</restrictions>
</valueType>