Defining validation rules
262 DataWindow .NET
GetText returns a string. Be sure to use a data conversion function (such as
Integer or Real) if you want to compare the entered value with a datatype other
than string.
For more on the
GetText function and text patterns, see the DataWindow Object
Reference.
Referring to other
columns
You can refer to the values in other columns by specifying their names in the
validation rule. You can paste the column names in the rule using the Columns
box.
Examples
Here are some examples of validation rules.
Example 1 To check that the data entered in the current column is a positive
integer, use this validation rule:
Integer(GetText( )) > 0
Example 2 If the current column contains the discounted price and the
column named
Full_Price contains the full price, you could use the following
validation rule to evaluate the contents of the column using the
Full_Price
column:
Match(GetText( ),"^[0-9]+$") AND
Real(GetText( )) < Full_Price
To pass the validation rule, the data must be all digits (must match the text
pattern
^[0-9]+$) and must be less than the amount in the Full_Price column.
Notice that to compare the numeric value in the column with the numeric value
in the
Full_Price column, the Real function was used to convert the text to a
number.
Example 3 In your company, a product price and a sales commission are
related in the following way:
• If the price is greater than or equal to $1000, the commission is between
10 percent and 20 percent
• If the price is less than $1000, the commission is between 4 percent and 9
percent