Typed data definition examples in the type definition file
The following typed data definition example defines a typed DataField named Date. The default descriptor for the Date data definition defines a converter that handles XML and default conversions. The converter takes a mask parameter. The DateConverter uses this mask as a pattern to perform the conversions. The definition also associates a validator that only allows dates in the year 2000.
The following typed data definition example defines a typed DataField named Money. The default descriptor for the Money typed data definition defines two converters: one for default conversion type and another for the host conversion type. Although the implementation class for both converters is the same, the definition cannot use a comma separated list of conversion types because they require different parameters. The definition is also a validator that takes no parameters.
The following typed data definition example defines a typed DataField named AccountNumber. The default descriptor for the AccountNumber typed data definition also defines a converter that handles XML and default conversions. In this case, the converter takes no parameters. It has also one validator with the parameters minLength and maxLength set to 8. This validator checks that the data element of this type has as value a numeric String of exactly eight digits.
The following typed data definition example defines a typed KeyedCollection named FundsTransferData. The FundsTransferData data definition has a default descriptor with the implClass attribute set to KCollDescriptor. This descriptor defines an instance of the KCollValidator as a validator that validates each of the elements contained in the KeyedCollection. The FundsTransferData data definition specifies four descriptors that define its structure: two of AccountNumber type called accountTo and accountFrom, one of Money type called amount, and one of Date type called transactionDate. The third descriptor overrides the default behavior for Money in general by specifying an upperLimit to be used by the validator. In the case of this definition, the maximum fund transfer amount is 1000.
Note The KCollValidator can only validate each of the elements contained in the keyed collection separately, and does not perform any cross-validation. If you require this cross-validation (for example, to check that the accountFrom value is different from the accountTo value), extend the KCollValidator to provide this functionality and use the resulting subclass instead.