- Data type of the fields
- Date format of the date fields
Validating these becomes simple, when using regular expressions with BPEL.
xp20:matches() is a function which can be used to compare data with regular expressions. This function returns true when the input matches the given expression.
Lets take them case by case
- Validation of alpha fields can be done as
xp20:matches(bpws:getVariableData('Variable_firstname'),'^[A-Z]*$')
2. Validation of numeric fields can be done as
xp20:matches(bpws:getVariableData('Variable_streetnumber'),')^[0-9]*$')
3. Validation of date field with format yyyymmdd can be done as
xp20:matches(bpws:getVariableData('Date'),'^(1920)\d\d(0[1-9]1[012])(0[1-9][12][0- 9]3[01])$')
4. Validation of datetime field can be done as
xp20:matches(bpws:getVariableData('Variable_datetime'),'^([1-9][0-9]*)?[0-9]{4}(1[0-2]0[1-9])(3[0-1]0[1-9][1-2][0-9])(2[0-3][0-1][0-9])[0-5][0-9][0-5][0-9]$')
xp20:matches takes string input.So if a variable is not string, please typecast them to string to get the results.
eg : xp20:matches(string(bpws:getVariableData('Variable_firstname')),'^[A-Z]*$')