Edit Validate rules
Format - 1 (Display custom message)
- The password must be atleast 8 - 15 character
- Include both lower and upper case characters
- Include at least one number are symbol
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
// regex to check password
String regex= ("^(?=.*[a-z])(?=.*[A-Z])(?=.*\\d)(?=.*[@#$%^&+=!])(?=\\S+$).{8,15}$");
// 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;
// Custom message
theProperty.addMessage("Be atleast 8 - 15 characters long");
theProperty.addMessage("Include both lower and upper case characters");
theProperty.addMessage("Include at least one number are symbol");
// Pattern class contains matches() method to match the given string and regular expression
java.util.regex.Matcher m = p.matcher(theValue);
return m.matches();
Format - 2 (Display property name as error)
- The password must be atleast 8 - 15 character
- Include both lower and upper case characters
- Include at least one number are symbol
1
2
3
4
5
6
7
8
9
10
// Regex to check valid Password
String regex= ("^(?=.*[a-z])(?=.*[A-Z])(?=.*\\d)(?=.*[@#$%^&+=!])(?=\\S+$).{8,15}$");
// 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();
Reference
Click Here - More details from pega academy for Edit Validate rules
Comments powered by Disqus.