Data integrity is enforced with validation and conversion business rules. The Project Designer can quickly create and configure generic business rules with a single click. JavaScript, SQL, and Code (C#/Visual Basic) validators and converters are created from the context menu of the fields in Project Explorer.
Converter
The generic converter will convert the field value to uppercase.
For example, the Category Name field in the Categories controller has been configured with the default SQL converter. The sample script is shown below.
if @CategoryName is not null and
(@Arguments_CommandName <> 'Calculate' or
@Arguments_Trigger = 'CategoryName')
begin
set @CategoryName = upper(@CategoryName)
end
The user may enter any value into the field.
When focus is shifted away from the field, the conversion will take place.
SQL and code validators are executed on the server.
Validator
The generic validator will ensure that the field value is not blank.
The Description field of Categories controller has been configured with the default JavaScript validator:
var fieldValue = [Description];
if (fieldValue == null) {
// prevent the default action processing
this.preventDefault();
// set the focus on the field and display an error
this.result.focus('Description', 'Required field.');
}
After typing a category name, pressing OK will display a message next to the Description field, despite the fact that the field is not marked as required.
These sample validators and converters can be expanded to perform more complex operations to fulfill specific business requirements. Any single validator or converter can handle multiple fields when necessary.