Package org.passay.rule
Class LengthRule
java.lang.Object
org.passay.rule.LengthRule
- All Implemented Interfaces:
Rule
Rule for determining if a password is within a desired length. The minimum and maximum lengths are used inclusively
to determine if a password meets this rule.
-
Field Summary
Fields -
Constructor Summary
ConstructorsConstructorDescriptionCreates a new length rule with lengths unset.LengthRule(int length) Creates a new length rule with the supplied length.LengthRule(int minLength, int maxLength) Create a new length rule. -
Method Summary
Modifier and TypeMethodDescriptionCreates the parameter data for the rule result detail.protected RuleResultMetadatacreateRuleResultMetadata(PasswordData password) Creates the rule result metadata.intReturns the maximum password length.intReturns the minimum password length.toString()validate(PasswordData passwordData) Validates the supplied password data per the requirements of this rule.
-
Field Details
-
ERROR_CODE_MIN
Error code for password too short.- See Also:
-
ERROR_CODE_MAX
Error code for password too long.- See Also:
-
minimumLength
private final int minimumLengthStores the minimum length of a password. -
maximumLength
private final int maximumLengthStores the maximum length of a password.
-
-
Constructor Details
-
LengthRule
public LengthRule()Creates a new length rule with lengths unset. The defaults are 0 and Integer.MAX_VALUE respectively. -
LengthRule
public LengthRule(int length) Creates a new length rule with the supplied length. Both the minimum and the maximum length will be set to this value.- Parameters:
length- length of password
-
LengthRule
public LengthRule(int minLength, int maxLength) Create a new length rule.- Parameters:
minLength- minimum length of a passwordmaxLength- maximum length of a password
-
-
Method Details
-
getMinimumLength
public int getMinimumLength()Returns the minimum password length.- Returns:
- minimum password length
-
getMaximumLength
public int getMaximumLength()Returns the maximum password length.- Returns:
- maximum length of a password
-
validate
Description copied from interface:RuleValidates the supplied password data per the requirements of this rule. -
createRuleResultDetailParameters
Creates the parameter data for the rule result detail.- Returns:
- map of parameter name to value
-
createRuleResultMetadata
Creates the rule result metadata.- Parameters:
password- data used for metadata creation- Returns:
- rule result metadata
-
toString
-