Skip to main content

Validating data against a pattern

1 Task

10 mins

Visible to: All users Applies to: Pega Platform '26
Intermediate
Data Integration
Data Management
English

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.

Note: This challenge has been configured with Single Sign-On (SSO) using your Pega Academy credentials. If you are not automatically signed in to the challenge environment after initializing the instance, you may use the credentials provided.

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.

You must initiate your own Pega instance to complete this Challenge.

Initialization may take up to 5 minutes so please be patient.

Detailed Tasks

1 Validating data against a pattern

Solution Builder Advanced Validating data against a pattern Doc Journey

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-Candidate class.
  • 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
Note: If you don't see any of the above fields, mark them as a relevant record. 

Directions

  1. In the Pega Platform instance for the challenge, enter the following credentials:
    1. In the User name field, enter SSA@TGB.
    2. In the Password field, enter pega123!.
  2. Create a new Edit Validate rule named Validate Aadhaar ID and enter the Java source logic as detailed in the Acceptance criteria.
  3. Create a new property named Aadhaar ID applied to the TGB-FW-HR-Data-Candidate class, convert to advanced configuration, and configure the Advanced tab values as detailed in the Acceptance criteria.
  4. Mark the property as a relevant record from the Actions menu.
  5. 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.
  6. Rearrange the fields in the Candidate View to match the order defined in the Acceptance criteria.


If you are having problems with your training, please review the Pega Academy Support FAQs.

Did you find this content helpful?

Want to help us improve this content?

We'd prefer it if you saw us at our best.

Pega Academy has detected you are using a browser which may prevent you from experiencing the site as intended. To improve your experience, please update your browser.

Close Deprecation Notice