Skip to main content

Defining a new ValueType

Adding a new ValueType​

If you want to define the implementation for a specific fieldFieldA property of a DataElement expanded to a database column and user interface input element. in your model, you can create your own (Simple)ValueType.

ValueTypes are added to the valueTypes directory within a component.

rentalComponent
└── model
├── rentalComponent.xml
└── valueTypes
├── LicensePlate.xml
└── Rating.xml

The xml itself should have root tag valueType and a type attribute (e.g. elements::SimpleValueType).


<valueType name="LicensePlate" type="elements::SimpleValueType">
<description>For license plate String values.</description>
<prototype name="String"/>
</valueType>

Prototype​

The Prototype defines the original ValueType and inherits all its properties.

Your custom ValueType will often extend one of the provided base types. For example, if you need a date (registrationDate) with a custom validation, you would extend the base ValueType Date and thus pick date as prototype.

Restrictions​

You can add restrictions on what values are valid for this specific type. A set of generic restrictions is provided out of the box:

  • NotNull
  • String has a maximum length
  • String must match a pattern
  • Minimum and maximum values
  • Number of Digits
  • Past or Future Date

Instead, you can also implement a custom restriction or validation to implement a business rule (e.g. an iban number is a string fieldFieldA property of a DataElement expanded to a database column and user interface input element. with a specific prefix and structure).

NativeTypes​

A NativeType is a definition of how a data type is handled in 1. a specific technology and 2. a specific concern or use-case.

In most cases, you extend your ValueType by building on an existing ValueType. If you want to override the behaviour of the selected Prototype, you can list one or many NativeTypes.

The below examples shows how a String fieldFieldA property of a DataElement expanded to a database column and user interface input element. will be rendered in the user interface, and more specific the table view of your UI.

<nativeType name="angular:table-cell:string">
<technology name="ANGULAR"/>
<concern>table-cell</concern>
<definition>{{ row.$name$ }}</definition>
</nativeType>

If you now wish to create a customValue type that should also be rendered as such a string (instead of a number for example), you can use link to this NativeType.

In this example, we specify an Integer ValueType by depending on the prototype Integer. We override the behaviour in the user interface by specifying the NativeType angular:table-cell:string.

<simpleValueType name="IntegerAsString">
<nativeTypes>
<nativeType>angular:table-cell:string</nativeType>
</nativeTypes>
<prototype>Integer</Prototype>
</simpleValueType>
caution

Since the data type of a fieldFieldA property of a DataElement expanded to a database column and user interface input element. has a widespread impact on the implementation, the amount of possible nativeTypes is quite large. Not all combination of NativeTypes are supported out of the box so make sure to validate any configuration.