The Table Validation Tool

Overview and Key Concepts

The Table Validation tool allows you to enumerate your assumptions about the data in specific tables and to test them, ensuring those tables contain valid data. For general information on how to use the Table Validation tool, see the Validating Input Data topic.

The Validation Algorithm

There may be cases where you need to write your own constraint functions or On Fail logic. Understanding how the Table Validation tool uses those components can be helpful. When the Table Validation tool validates data, it uses the following algorithm:

The tool loops over all ranges in all tables in table order and then in range order, as they are seen in the user interface. In this way, it visits each range.

When visiting a range, the tool creates a context associated with each rule connected to that range. The context stores a copy of the default Error Message for the rule. Then, the tool scans each row in the range from top to bottom. Within the row, cells are scanned from left to right.

When scanning a cell, the tool calls the Constraint function of each connected rule. Rules are tested in the order seen on the Rules tab. For each rule, the tool passes the cell's value and the context associated with the rule into the constraint function. If the function returns anything other than zero, then the value passes the rule.

If a Constraint function returns zero, then the tool calls the rule's On Fail callback. This callback allows the user to try to repair the value or update the error message. If the On Fail callback returns 0, the error message is logged.

The following pseudocode presents a summary of the algorithm used:

for each table:
    for each range:
        for each rule:
            create a context for the rule

        for each row in the range:
            for each column in the row:
                value := table[row][col]
                for each rule:
                    context := context associated with this rule    
                    result := constraint(value, context)
                    if result = 0:
                        result := onFail(value, context)
                        if result = 0:
                            log an error

        for each rule:
            delete the context

A critical part of this algorithm is the context. The context is a Simple Data Type, similar to a Process Flow token. The context has several purposes:

The Table Ranges Tab

The Table Ranges tab has the following properties:

Table List

The table list allows you to edit the Table Validation tool's list of table references. Select an item in the list to display its properties to the right of the list.

Table Area

The table area is in the upper right region of the Table Ranges tab. The table area has the following properties:

Ranges Area

The ranges area is in the lower right region of the Table Ranges tab. The ranges area has the following properties:

The Rules Tab

The Rules tab has the following properties:

The Rules List

You can use the Rules list to edit the set of available rules in this Table Validation tool. During validation, rules are checked in the order specified by this list.

Name

The Name property allows you to edit the name of the rule. The name of the rule appears in logged error messages.

Constraint

The Constraint property defines the function used to test values. You can edit the code of this field to define a function. That function should return a one if the value passes the test or a zero if it fails.

Fail if Range Empty

Check this box to log an error if a range connected to this rule is empty. This box should only be unchecked if attached to a range type that can be empty (Column, Row Headers, and Custom) and if the source table is valid with zero rows (such as a query with no matching rows).

Error Message

The Error Message property edits the default error message of the rule. This message is shown in the error log if a value fails the rule.

On Fail

The On Fail property defines a callback function. This function is optional. You can use it to repair an invalid value and/or update the error message. This function returns a one or a zero. If it returns a zero, the error is logged. If it returns a 1, the value is considered acceptable and no error is logged.

The Logged Errors Tab

The Logged Errors tab has the following properties:

Error Table

When you click the Validate button, the Error Table displays a list of all errors encountered during validation. If a given error has a valid table, row, and column, you can double-click on that error to open the table view and select the invalid cell.