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

  • ANY - Indicates that the field can accept any type of value and there's no need for validation.
  • XA - Indicates that only the alphabetic characters are allowed.
  • XAU - Indicates that only the UPPERCASE alphabetic characters are allowed.
  • XAN - Indicates that only the alphanumeric characters are allowed.
  • XANU - Indicates that only the UPPERCASE alphanumeric characters are allowed.
  • XN or N - Indicates that only the numeric input is allowed.
  • F - Uses the Double to parse the content to validate conformance.
  • I - Indicates that only the numeric input that can be converted as integer is allowed.
  • B - Indicates that only numeric input is allowed. This uses {@link BigDecimal} to parse the content to validate conformance.
  • D - Indicates that only date input is allowed. This converts the data using the standard date format of the framework {@link FrameworkConstants.DEFAULT_DATE_FORMAT}
  • X - Indicates that only SWIFT supported characters are allowed.
  • COLL - This attribute value cannot be used directly. This value is used internally within the application to model a collection data type.

mandatory

  • true - Indicates that the input for the specific field is mandatory.
  • false - Indicates that the input for the specific field is not 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

  • true - Indicates that the field must have multiple lines of input.
  • false - Indicates that the field must not have multiple lines of input.