Introduction
The WebRatio validation rule framework has been refactored in WebRatio 6.1. The goal of the refactoring is to allow an easiest integration in the tool of the custom validation rules. The way those validation are managed is now very similar to the way you manage the custom units. To get this result, also the predefined validation rules has been revisited.
Defining Validation Rules on Entry Units
In order to add a validation rule to an Entry unit, right click on the unit and choose the Add -> Validation Rule command. Choose from the opening dialog the Validation Rule to apply.
-
FORM NOT EMPTY(
). This rule checks that at least one field inside the form has a value.
-
Name: the name of the validation rule.
-
Error Message: the message to display when the validation fails.
Defining Validation Rules on Multi Entry Units, Multi Choice Units, Power Index Units
In order to add a validation rule to a Multi Entry unit, right click on the unit and choose the Add -> Validation Rule command. Choose from the opening dialog the Validation Rule to apply.
-
CHECK ITEMS(
). It checkes whether the number of checked instances corresponds to the wanted number or note. This validation rule can be applied only if the unit is rendered with checkboxes that permit to choose which instances to commit.
-
Name: the name of the validation rule.
-
Predicate: the operator for the comparison. The possibilities are: At Least, At Most, Exactly.
-
Item Count: the number of wanted checked items.
-
Error Message: the message to display when the validation fails.
Defining Validation Rules on Fields
Suppose you want to add to your project a page to test how each validation rule works.
-
Open your project and add a new Page.
-
Add an Entry Unit to the page.
-
Add a Field to the Entry Unit. Right click on the Entry unit and choose the Add Field command.
-
Add a Validation Rule to the field. In the Outline, right click on the field and choose the Add -> Validation Rule command.
-
Choose from the opening dialog the Validation Rule to apply. The list contains all the predefined validation rules plus all the custom ones.
Here is a list of the predefined validation rules.
-
CAPTCHA(
). It's the Captcha control code. It is a type of challenge-response test used in computing to ensure that the response is not generated by a computer. The process usually involves one computer (a server) asking a user to complete a simple test which the computer is able to generate and grade. Because other computers are unable to solve the Captcha, any user entering a correct solution is presumed to be human. These are the available properties:
-
Name: the name of the validation rule.
-
Characters: it defines the characters list to be used by the captcha code (default is ABCDEFGHIJKLMNPQRSTUVWXYZ123456789). It's possible to choose only a subset of characters changing the value of this property (e.g use only numbers - 123456789).
-
Ignore Case: it defines that the Captcha control ignore the case in which the user writes the letters.
-
Min Length: it defines the minimum number of characters to be used to create the control code (default is 6). If this value is set to a higher one respect to the maxLength it is ignored.
-
Max Length: it defines the maximum number of characters to be used to create the control code (default is 6). If this value is set to a lower one respect to the minLength it is ignored.
-
Min Font Size: it defines the minimum font size to be used in the control code (default is 20).
-
Max Font Size: it defines the maximum font size to be used in the control code (default is 35).
-
Font Names: it defines the list of the available font families. The list is pipe (|) separated (default is Arial|Tahoma|Verdana).
-
Width: it defines the width of the control code container (default is 200).
-
Height: it defines the height of the control code container (default is 50).
-
Color Ranges: it defines the range of colors to be used to render the characters. It's expressed in RGB. It's composed by three couple of values (default is 0,100,0,100,0,100).
-
Background: it defines the color of the control code backgroung. It's expressed in RGB (default value is 255,255,255).
-
Error Message: the message to display when the validation fails.
-
COLLECTION(
). It checkes whether the value of the field is contained or not in the collection of the values provided. It's possible to provide a static list of values or connect the list to the value of an entity attribute. These are the available properties:
-
Name: the name of the validation rule.
-
Predicate: it defines whether the value should be "In Collection" or "Not in Collection".
-
Values: the list of static values that represent the collection
-
Entity: the Data Model Entity from which it's possible to choose an attribute.
-
Attribute: the Attribute from which the collection to make the comparison is extracted. The list of available attributes are those connected to the Entity chosen.
-
Ignore Case: states whether the comparison has to take into account the Case of the values or not.
-
Error Message: the message to display when the validation fails.
-
COMPARE(
). It compares the value of the field with another value, which can be provided in a static way or it can be the value of another field. These are the available properties:
-
Name: the name of the validation rule.
-
Predicate: the operator for the comparison. The possibilities are: Equal, Less or Equal , Less Than, Greather or Equal, Greather Than, Not Equal.
-
Ignore Case: states whether the comparison has to take into account the Case of the values or not.
-
Value Field: a field of the Entry Unit that provide its value as second term for the comparison.
-
Value: a constant value which is used as second term for the comparison.
-
Error Message: the message to display when the validation fails.
-
CREDIT CARD(
). It checks whether the value provided is a valid credit card number or not. These are the available properties:
-
Name: the name of the validation rule.
-
Error Message: the message to display when the validation fails.
-
EMAIL(
). It checks whether the value provided is a valid email or not. These are the available properties:
-
Name: the name of the validation rule.
-
Error Message: the message to display when the validation fails.
-
LIKE(
). It checks whether the value provided is like the provided one. These are the available properties:
-
Name: the name of the validation rule.
-
Predicate: the operator for the comparison. The possibilities are: Starts With, Contains, Ends With, Not Starts With, Not Contains, Not Ends With.
-
Ignore Case: states whether the comparison has to take into account the Case of the values or not.
-
Value Field: a field of the Entry Unit that provide its value as second term for the comparison.
-
Value: a constant value which is used as second term for the comparison.
-
Error Message: the message to display when the validation fails.
-
MANDATORY(
). It checks that a value for the field is provided. These are the available properties:
-
Name: the name of the validation rule.
-
Error Message: the message to display when the validation fails.
-
REGULAR EXPRESSION(
). It allows to check if the value provided sutisfies the regular expression written in the specific property. These are the available properties:
-
Name: the name of the validation rule.
-
Regular Expression: the regular expression to be used.
-
Ignore Case: states whether the comparison has to take into account the Case of the values or not.
-
Error Message: the message to display when the validation fails.
-
TYPE.(
). It checks whether the value provided is of a specific type. It's possible to specify also the pattern to be checked.
-
Name: the name of the validation rule.
-
Type: the type of the information. The available choices are: Byte, Boolean, Decimal, Date, Float, Integer, Long, Short, Time, Timestamp.
-
Pattern: the pattern that the value has to satisfy.
-
Error Message: the message to display when the validation fails.
-
VALUE LENGTH.(
). It checks whether the value provided is long as many characters as the rule states.
-
Name: the name of the validation rule.
-
Predicate: the operator for the comparison. The possibilities are: Exactly, Not, Min, Max .
-
Value: the length to be checked.
-
Error Message: the message to display when the validation fails.
-
CHECK ITEMS(
). It checkes whether the number of checked instances corresponds to the wanted number or note. This validation rule can be applied only if the field is a MultiSelectionField.
-
Name: the name of the validation rule.
-
Predicate: the operator for the comparison. The possibilities are: At Least, At Most, Exactly.
-
Item Count: the number of wanted checked items.
-
Error Message: the message to display when the validation fails.