Cartella implements both server-side and client-side validation. There are four tables related to validation. They are:

  • Table_ValidationType

  • Table_ValidationProperties

  • Table_EditFieldValidation

  • Table_ValidationPropertyValues

All validation rules can be added to these tables with no additional code with the exception of the CustomRule.

How Validation Works

When the application starts and the CartellaGlobalManager is created, the Validation rules (all based on ValidationRule ) are retrieved from the database. The rules are stored in a dictionary in the CartellaGlobalManager until needed. During construction of the Validation rules, each property of the rule is set by calling Parse on the class that is listed in Table_ValidationProperties.

Caution

Rules with custom property types must have a static Parse method in that class.

All built-in edit forms use the validation rules. For example, a StringLengthRule associated with a text area element attempts to limit the string length. When the form is submitted, an AJAX call is made with the field values. Validation is performed at the object level. This way, even if the edit form is not used, a standard set of validations can be applied globally. These validations are performed just prior to saving the record to the database. All validation rules for an object are run. If any fail, a ValidationException is thrown. The ValidationException has a property called Errors which is an array of ValidationError. On the edit form, if any fields have non-valid data, the user is presented with the Non-Valid message (ErrorMessage which comes from NotValidMessage) associated with the rule.