Designer - How To:
One of the powerful feature in Quick Objects Designer allows you add Validation criteria to fields. This criteria gets saved with your project, and every time you re-generate your base classes, the validation code is automatically updated to reflect the validation defined in the designer.
By default the Business Logic Framework automatically assigns a BaseFieldValidator to each field. This is limited to enforcing column level constraints defined in your database, such as NOT NULL or the maximum length of the field etc.
Before the release of version 3.5 a developer needed to write the validation code by hand. Even though a adding a single validator only needed about 2-3 lines of code, but we wanted to streamline the process even further and reduce the amount of time it would take to change such validation rules. Starting version 3.5 not only the validation framework is improved, but you can use the Designer to add validation rules and have it generate the code for you.
In this tutorial we will walk through the basic steps involved in adding a validator.
Prerequisite:
Start the Quick Objects Designer, and then open the "*.qos" file of your choice, or get the schema from a database and save a new qos file. For this example, we have used the QO_SHOP sample database included with the installation of the product.
1. From the tables grid on the left, select the table and then on the Columns tab, select the column where you would like to add certain validation. In our example, we have selected the Users table, and Email column.
2. Right next to the Column's Properties tab, there is a tab called Validators. Select the Validators tab, and then click on the "Add" button on the toolbar inside the Validators tab.
3. From the drop down menu choose the "Regular Expression", and you will be shown the properties of the Regular Expression validator.
4. The Custom Error Message is a excellent way to customize your validator. Each type of validator provides different options that can be used to format the resulting error message of a validator. Essentially when a validator fails and the ErrorString property is requested, instead of returning the standard error message a formatted/customized error message is returned. This gives you complete control over what should be displayed when a validation fails.

Click to enlarge