In this post under Passay, I will explain with example the purpose of “NumberRangeRule” class. NumberRangeRule takes a range of numbers and verifies whether the user entered password doesn’t contain numbers in that range. So “NumberRangeRule” constructor takes two arguments1) starting number (inclusive)2) ending number (exclusive) Below is the complete Main class for your reference…… Continue reading NumberRangeRule example
Tag: Passay
Generating random password
In this post under Passay, I will show with example how to generate random password. For our example I will generate a random password of length 15 characters containing english lowercase characters, uppercase characters, special characters and digits. Below is the complete code for your reference. Main class 1 package defaultPackage;2 3 import java.util.ArrayList;4 import…… Continue reading Generating random password
Verifying password has alphanumeric and special characters
In this post under Passay, I will show with example how to verify whether a password has alphanumeric and special characters. Below is the Main class for our example Main class 1 package defaultPackage;2 3 import java.util.ArrayList;4 import java.util.List;5 import java.util.Scanner;6 7 import org.passay.CharacterRule;8 import org.passay.EnglishCharacterData;9 import org.passay.PasswordData;10 import org.passay.PasswordValidator;11 import org.passay.Rule;12 import org.passay.RuleResult;13 14…… Continue reading Verifying password has alphanumeric and special characters
Verifying password is of specified length
In this post under Passay, I will show with example how to verify that the password is of specified length. Below is the complete code for your reference Main class 1 package defaultPackage;2 3 import org.passay.LengthRule;4 import org.passay.PasswordData;5 import org.passay.PasswordValidator;6 import org.passay.Rule;7 import org.passay.RuleResult;8 9 public class Example3 {10 public static void main(String[] args) {11…… Continue reading Verifying password is of specified length
Displaying meaningful error messages when password validation fails
In this post under Passay, I will show with example how to display error messages for failed password validation. Below is the complete code for your reference. Main class 1 package defaultPackage;2 3 import java.util.List;4 import java.util.Scanner;5 6 import org.passay.LengthRule;7 import org.passay.PasswordData;8 import org.passay.PasswordValidator;9 import org.passay.Rule;10 import org.passay.RuleResult;11 12 public class Example2 {13 public static…… Continue reading Displaying meaningful error messages when password validation fails