# Data validation

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

<span class="notranslate">attribute-validator contains the following attributes:</span>

<div id="bkmrk-attribute-usage-expr"><table class="confluenceTable tablesorter tablesorter-default stickyTableHeaders" role="grid"><thead class="tableFloatingHeaderOriginal"><tr class="tablesorter-headerRow" role="row"><th aria-disabled="false" aria-label="Attribute: No sort applied, activate to apply an ascending sort" aria-sort="none" class="confluenceTh tablesorter-header sortableHeader tablesorter-headerUnSorted" data-column="0" role="columnheader" scope="col" style="width: 116px;" tabindex="0"><div><div>**Attribute**</div></div></th><th aria-disabled="false" aria-label="Usage: No sort applied, activate to apply an ascending sort" aria-sort="none" class="confluenceTh tablesorter-header sortableHeader tablesorter-headerUnSorted" data-column="1" role="columnheader" scope="col" style="width: 693px;" tabindex="0"><div><div>**Usage**</div></div></th></tr></thead><tbody aria-live="polite" aria-relevant="all"><tr role="row"><td class="confluenceTd" style="width: 116px;">expr

</td><td class="confluenceTd" style="width: 693px;">EL expression pointing to the attribute to validate

</td></tr><tr role="row"><td class="confluenceTd" style="width: 116px;">friendlyName

</td><td class="confluenceTd" style="width: 693px;">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.

</td></tr><tr role="row"><td class="confluenceTd" style="width: 116px;">notNull

</td><td class="confluenceTd" style="width: 693px;">true is the attribute is mandatory</td></tr><tr role="row"><td class="confluenceTd" colspan="1" style="width: 116px;">maxLength</td><td class="confluenceTd" colspan="1" style="width: 693px;">Maximum length of the attribute</td></tr><tr role="row"><td class="confluenceTd" colspan="1" style="width: 116px;">minValue</td><td class="confluenceTd" colspan="1" style="width: 693px;">Minimum value in case of numeric attributes</td></tr><tr role="row"><td class="confluenceTd" colspan="1" style="width: 116px;">maxValue</td><td class="confluenceTd" colspan="1" style="width: 693px;">Maximum value in case of numeric attributes</td></tr></tbody></table>

</div><span class="notranslate">attribute-script contains a script that will be executed to validate the business object.</span>

<span class="notranslate">Example:</span>

```western
<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>
```