Skip to main content

Data validation

The validation tag is responsible for performing basic checks regarding mandatory attributes and valid attribute values before being submitted to the persistence handler. The validation tag may contain one or more attribute-validation and script-validation tags. The verification will be performed before running the insert or update handler.

attribute-validator contains the following attributes:

Attribute
Usage

expr

EL expression pointing to the attribute to validate

friendlyName

Text to be presented to the user on validation failure. If there is a ZK label with this text, it will be localized based on current user language preference.

notNull

true is the attribute is mandatory
maxLengthMaximum length of the attribute
minValueMinimum value in case of numeric attributes
maxValueMaximum value in case of numeric attributes

attribute-script contains a script that will be executed to validate the business object.

Example:

<datanode name="country">
    <validation>
        <attribute-validation expr=”${instance.abbrevisation}”
                notNull=”true” friendlyName=”Two letter abbrv.”>
        <script-validation>
            if (instance.abbreviaton.equals(“CT”))
            {
                throw new RuntimeException (“Catalonia is not a country yet”);
            }
        </script-validation>
    </validation>
        ...
</datanode>