Question

23
Views
Close popover
Nitin Chandra (NitinP)
Evonsys

Evonsys
IN
NitinP Member since 2020 1 post
Evonsys
Posted: March 23, 2021
Last activity: March 23, 2021

SSN Validation using Edit Validate Rule

Hi, 

I have a requirement to validate SSN, only when Citizenship is US.

Below is the code for OOTB, SSN edit validate rule.

String SSN = "^(\\d{3})-?\\d{2}-?\\d{4}$"; java.util.regex.Pattern p = java.util.regex.Pattern.compile(SSN); java.util.regex.Matcher m = p.matcher(theValue); String[] strArr = theValue.split("-"); int numDashes = strArr.length - 1; boolean isSSN = m.matches(); if((isSSN == false) || (numDashes == 0)){     return false; } if(theValue.length()!=11) {     return false; } return true;  

Please let me know how to modify the code according to my requirement.

Thanks.

***Edited by Moderator: Pooja Gadige to add platform capability tag***
Pega Platform 8.5 Low-Code App Development