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
The Sales table has two columns, Price and Commission. The validation rule for the Commission column is:
(Number(GetText( )) >= If(price >= 1000, .10, .04)) AND (Number(GetText( )) <= If(price >= 1000, .20, .09))
A customized error message for the Commission column is:
"Price is " + if(price >= 1000, "greater than or equal to","less than") + " 1000. Commission must be between " + If(price >= 1000,".10", ".04") + " and " + If(price >= 1000, ".20.", ".09.")