Package org.passay
Class LengthRule
- java.lang.Object
-
- org.passay.LengthRule
-
-
Field Summary
Fields Modifier and Type Field Description static String
ERROR_CODE_MAX
Error code for password too long.static String
ERROR_CODE_MIN
Error code for password too short.
-
Constructor Summary
Constructors Constructor Description LengthRule()
Creates 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
All Methods Instance Methods Concrete Methods Modifier and Type Method Description protected Map<String,Object>
createRuleResultDetailParameters()
Creates the parameter data for the rule result detail.protected RuleResultMetadata
createRuleResultMetadata(PasswordData password)
Creates the rule result metadata.int
getMaximumLength()
Returns the maximum password length.int
getMinimumLength()
Returns the minimum password length.void
setMaximumLength(int maxLength)
Sets the maximum password length.void
setMinimumLength(int minLength)
Sets the minimum password length.String
toString()
RuleResult
validate(PasswordData passwordData)
Validates the supplied password data per the requirements of this rule.
-
-
-
Field Detail
-
ERROR_CODE_MIN
public static final String ERROR_CODE_MIN
Error code for password too short.- See Also:
- Constant Field Values
-
ERROR_CODE_MAX
public static final String ERROR_CODE_MAX
Error code for password too long.- See Also:
- Constant Field Values
-
-
Constructor Detail
-
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 Detail
-
setMinimumLength
public void setMinimumLength(int minLength)
Sets the minimum password length.- Parameters:
minLength
- minimum length of a password
-
getMinimumLength
public int getMinimumLength()
Returns the minimum password length.- Returns:
- minimum password length
-
setMaximumLength
public void setMaximumLength(int maxLength)
Sets the maximum password length.- Parameters:
maxLength
- maximum length of a password
-
getMaximumLength
public int getMaximumLength()
Returns the maximum password length.- Returns:
- maximum length of a password
-
validate
public RuleResult validate(PasswordData passwordData)
Description copied from interface:Rule
Validates the supplied password data per the requirements of this rule.
-
createRuleResultDetailParameters
protected Map<String,Object> createRuleResultDetailParameters()
Creates the parameter data for the rule result detail.- Returns:
- map of parameter name to value
-
createRuleResultMetadata
protected RuleResultMetadata createRuleResultMetadata(PasswordData password)
Creates the rule result metadata.- Parameters:
password
- data used for metadata creation- Returns:
- rule result metadata
-
-