Defining Data Validation
The syntax for the <product_code>.xml is shown in the following code snippet:
<?xml version="1.0" encoding="UTF-8"?> <validate> <FUNCTIONCODE_ACTIONCODE> <fieldType attribute1="value" attribute2="value" ... attributen="value"> FIELD_NAME1 </fieldType> . . . <fieldType attribute1="value" attribute2="value" ... attributen="value"> FIELD_NAMEn </fieldType> <collection name="COLLECTION1" mandatory="true"> <fieldType attribute1="value" attribute2="value" ... attributen="value"> FIELD_NAME1 </fieldType> . . . <fieldType attribute1="value" attribute2="value" ... attributen="value"> FIELD_NAMEn </fieldType> <collection name="COLLECTION2" mandatory="false"> <fieldType attribute1="value" attribute2="value" ... attributen="value"> FIELD_NAME1 </fieldType> </collection> </collection> </FUNCTIONCODE_ACTIONCODE> </validate>
Â
The <product_code>.xml file must contain the following tags for validating the data at server-side:
- The <validate> tag is the parent tag that consists all the <FUNCTIONCODE_ACTIONCODE> tags.
- The <FUNCTIONCODE_ACTIONCODE> tag is used to identify the request for which the validations have to be performed. The function and action codes within the input params of an AJAX call is used to find the specific <FUNCTIONCODE_ACTIONCODE> tag within the<product_code>.xml file for executing the necessary validation.
- The <FUNCTIONCODE_ACTIONCODE> tag consists of the following tags:
- The <fieldType> tag is used to identify the fields that need validation. Independent <fieldType> tags must be specified for every field that is required to be validated. The attributes of the <fieldType> tag enable you to define the validations for any specific field.
- The <collection> tag is used to identify the container fields that encompass other fields within it. As mentioned in the above point, independent <fieldType> tags must be specified for every field within the container field that requires validation.
Attributes of the <fieldType> Tag
The details of the attributes of the <fieldType> tag and their values are provided in the following table:
Attribute | Acceptable Values |
---|---|
Type |
|
mandatory |
|
inclusive | Indicates that the special characters provided as the value for this attribute must be considered as valid input. |
specialCharacter | Indicates that the special characters provided as the value for this attribute must NOT be considered as valid input. |
size | Indicates the value length i.e., the number of characters that can be provided as the input. |
multiline |
|