Validation rule example

The steps that follow describe how to import a validation rule file into Unica Plan, add it to a template, and test it.

Before you begin

The following example rule ensures that the value supplied for the numEmps field in a grid is 10 - 1000.
<?xml version="1.0" encoding="UTF-8"?>
   <validation-rules xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance">
      <rule validationType="ROW">
      <name>Range Check</name>
      <desc>Checks Range for numeric type. Note: for field numEmps</desc>
      <class>com.unicacorp.uap.grid.validation.rule.basic.RangeCheckRule</class>
      <enable>true</enable>
      <applies-to-tvc-id>vendors</applies-to-tvc-id>
      <set-property property="minValue" value="10"/>
      <set-property property="maxValue" value="1000"/>
      <set-property property="column" value="dyn_vendors.numEmps"/>
   </rule>
</validation-rules>

In this rule, the numEmps field is on a form with an internal name of vendors. The procedure that follows assumes that you have this form set up on your system.

Procedure

  1. Create an XML file to contain the example validation rule.
  2. Upload the rules file into Unica Plan:
    1. Click Settings > Plan Settings > Template Configuration > Rules.
    2. Click Add Rules Definition.
    3. In the Update Rule dialog box, supply an identifying name and specify your XML file.
    4. Click Continue to add the rules file to Unica Plan.
  3. Assign the rules file to a tab on a template.
    1. Click Settings > Plan Settings > Template Configuration > Templates.
    2. Choose a template, and then click its Tabs tab.
    3. Click Add Tab. For the Form, select vendors. For the Data Validation Rules, select the identifying name of your rule.

      The system supplies the Data Validation Class when you select a rules file.

  4. Save your changes and use the template to create an object.
  5. To test the rule, enter invalid data in the empNum field.

    For example, enter 5000. If you receive an error message, the rule is working as designed.