4.7Validators setting
4.7.1 Definitions & concepts
4.7.2 Principle
4.7.3 The RequiredFieldValidator tag
4.7.6 The CompareValidator tag
4.7.8 The RegularExpressionValidator tag
4.7Validators setting
4.7.1Definitions & concepts
Validators allow checking data type and format. This check can be carried out on the customer’s or server’s level.
Validators types are:
- Syntaxic (date, alphanumeric, size, numbers, double precision, email, …),
- Semantic (dynamic : beginning date < end date, static : field included between two calculated values),
- Required field,
- Display parameters (colors, visibility, enabled, disabled…) .
4.7.2Principle
The following table is a list of the various technical type management rules categories or validators that may be defined on the mock-up:
| Category | Tag | Comment |
| Required Field | RequiredFieldValidator | Data in field is Required |
| Comparaison | CompareValidator | Compares the value of a field filled by a user with another one |
| Format | FormatValidator | Defines the field format: email, Zip code, date, … etc. |
| Range | RangeValidator | Defines the value of a field that must be range within a given interval. |
| Regular Expression | RegularExpressionValidator | Checks the value format in comparison with a regular expression. |
| Custom | CustomValidator | Executes a specific validation as decided by the user. |
Validator common attributes are:
| Attribute | Required | Description |
| Id | Y | Unique tag ID in the page |
| forid | Y | ID of the item to be validated |
| errormessage | N | error message to display in case of validation error |
| styleclass | N | Error message to display style CSS class |
Using the example of a Required « UserName » field, the validation tag will have the following shape:
<bluage:RequiredFieldValidator
id = "RG_001"
forid = "UserName "
errormessage = "Please choose a username"
styleclass= = "error "
/>
A « Please choose a username » message will be displayed in case of validation failure.
| If the « errormessage » attribute is not filled in, a default error message will be displayed (the message key in the bundle is: NomDuValidator_ErrorMessage, example RequiredFieldValidator_ErrorMessage), if no message must be displayed then ErrorMessage=" " must be used. |
| The « ErrorMessages » tag allows to display validation errors and errors from application. |
| The two most common ways of dealing with error messages related to data validation are the following ones :
|
