Validating data against a pattern
1 Task
10 mins
Scenario
You are a Solution Builder working on TGB's HRApps application. TGB is opening an Indian branch office and must collect a valid Aadhaar ID from candidates who select India as their country. The Aadhaar ID field must only appear and be required when the user selects India (IND) in the Collect Personal Details Step.
Create an Edit Validate rule that enforces the Aadhaar ID format using a regular expression, create the Aadhaar ID property with the validation applied, and add the field to the Collect Personal Details Step view with the appropriate required and visibility conditions.
The following table provides the credentials you need to complete the challenge:
| Role | User name | Password |
|---|---|---|
| Solution Builder | SSA@TGB | pega123! |
After completing this challenge, you should be able to:
- Create an Edit Validate rule using a Java regular expression.
- Create a property with advanced configuration and an assigned validate rule.
- Mark a property as a relevant record.
- Configure required and visibility conditions on a field in a Case Type view.
Detailed Tasks
1 Validating data against a pattern
Use the technical documentation linked in the Journey map above to complete the assigned tasks. The technical documentation might have more information than you need to complete the tasks.
Acceptance criteria
Task 1: Create the Validate Aadhaar ID Edit Validate rule
- An Edit Validate rule named Validate Aadhaar ID exists.
- The rule implements the following Java source logic:
// Regex to check valid Aadhaar number
String regex= "^[2-9]{1}[0-9]{3}\\s[0-9]{4}\\s[0-9]{4}$";// Compile the ReGex
java.util.regex.Pattern p = java.util.regex.Pattern.compile(regex);// If the string is empty, return false
if (theValue == null || theValue.trim().equals("")) return false;// Pattern class contains matcher() method to match the given string and the regular expression
java.util.regex.Matcher m = p.matcher(theValue);// Return if the string matched the ReGex
return m.matches();
Task 2: Create the Aadhaar ID property
- A property named Aadhaar ID is configured in the
TGB-FW-HR-Data-Candidateclass. - The property is configured using advanced configuration with the following values on the Advanced tab:
Field Value Max length 14 Expected length 14 Use validate ValidateAadhaarID - The property is marked as a relevant record.
Task 3: Add the Aadhaar ID field to the Collect Personal Details Step view
- Mark pyCountryCode under @baseclass as Relevant record.
- The Aadhaar ID field is added to the Candidate View within the Collect Personal Details Step User Action view under Candidate Case type.
- The field has a Required condition configured as:
- Type: Custom Condition
- Field: Country by Code, Operator: is equal to, Value: IND
- The field has a Visibility condition configured as:
- Type: Custom Condition
- Field: Country by Code, Operator: is equal to, Value: IND
- The fields in the Candidate View are arranged in the following order:
Order Field 1 First Name 2 Last Name 3 Participant email 4 Taxpayer Identification Number 5 Home Phone 6 Aadhaar ID 7 Address line1 8 City/Town 9 Postal Code 10 State/County 11 Country by Code
Directions
- In the Pega Platform instance for the challenge, enter the following credentials:
- In the User name field, enter SSA@TGB.
- In the Password field, enter pega123!.
- Create a new Edit Validate rule named Validate Aadhaar ID and enter the Java source logic as detailed in the Acceptance criteria.
- Create a new property named Aadhaar ID applied to the
TGB-FW-HR-Data-Candidateclass, convert to advanced configuration, and configure the Advanced tab values as detailed in the Acceptance criteria. - Mark the property as a relevant record from the menu.
- Open the Candidate Case Type in App Studio, navigate to the Collect Personal Details Step, and open the User Action view to add the Aadhaar ID field with required and visibility conditions as detailed in the Acceptance criteria.
- Rearrange the fields in the Candidate View to match the order defined in the Acceptance criteria.
Want to help us improve this content?