Extending postal code validation to other countries
Pega Government Platform includes an edit validate rule that you can use in flow action rules to verify if the postal codes that users enter have the correct format. By default, the rule includes validation for postal codes for the United States, India, Canada, and the United Kingdom. Enable the tools that validate postal codes for more countries by extending the rule to cover other countries that you define in your application, for example, Canada.
In Dev Studio, search for and select the PostalCodeFormat edit validate rule.
Include strings for other countries by editing the java source. The following example demonstrates the string for Canada:
String canZIP= "^[ABCEGHJKLMNPRSTVXY]\\d[ABCEGHJKLMNPRSTVWXYZ]( )?\\d[ABCEGHJKLMNPRSTVWXYZ]\\d$"; if(CountryCode.equals("CAN")) { p = java.util.regex.Pattern.compile(canZIP);
m = p.matcher(theValue); isvalidZIP = m.matches(); if((isvalidZIP == false) ){ return false; } }
Previous topic Extending state labels Next topic Applying postal code validation in processes