Class NumberRangeRule

java.lang.Object
org.passay.rule.NumberRangeRule
All Implemented Interfaces:
Rule

public class NumberRangeRule extends Object implements Rule
Rule for determining if a password contains any number within a defined range, lower inclusive, upper exclusive.
  • Field Details

    • ERROR_CODE

      public static final String ERROR_CODE
      Error code for whitespace rule violation.
      See Also:
    • reportAllFailures

      protected final boolean reportAllFailures
      Whether to report all sequence matches or just the first.
    • lowerRange

      private final int lowerRange
      Lower end of the range.
    • upperRange

      private final int upperRange
      Upper end of the range.
    • matchBehavior

      private final MatchBehavior matchBehavior
      Where to match each number.
  • Constructor Details

    • NumberRangeRule

      public NumberRangeRule(int lower, int upper)
      Creates a new number range rule.
      Parameters:
      lower - end of the number range, inclusive
      upper - end of the number range, exclusive
    • NumberRangeRule

      public NumberRangeRule(int lower, int upper, boolean reportAll)
      Creates a new number range rule.
      Parameters:
      lower - end of the number range, inclusive
      upper - end of the number range, exclusive
      reportAll - whether to report all matches or just the first
    • NumberRangeRule

      public NumberRangeRule(int lower, int upper, MatchBehavior behavior)
      Creates a new number range rule.
      Parameters:
      lower - end of the number range, inclusive
      upper - end of the number range, exclusive
      behavior - how to match number range
    • NumberRangeRule

      public NumberRangeRule(int lower, int upper, MatchBehavior behavior, boolean reportAll)
      Creates a new number range rule.
      Parameters:
      lower - end of the number range, inclusive
      upper - end of the number range, exclusive
      behavior - how to match number range
      reportAll - whether to report all matches or just the first
  • Method Details

    • getReportAllFailures

      public boolean getReportAllFailures()
      Returns whether to report all matches or just the first.
      Returns:
      whether to report all matches or just the first
    • getLowerRange

      public int getLowerRange()
      Returns the lower range for this rule.
      Returns:
      lower range
    • getUpperRange

      public int getUpperRange()
      Returns the upper range for this rule.
      Returns:
      upper range
    • getMatchBehavior

      public MatchBehavior getMatchBehavior()
      Returns the match behavior for this rule.
      Returns:
      match behavior
    • validate

      public RuleResult validate(PasswordData passwordData)
      Description copied from interface: Rule
      Validates the supplied password data per the requirements of this rule.
      Specified by:
      validate in interface Rule
      Parameters:
      passwordData - to verify (not null).
      Returns:
      details on password verification
    • createRuleResultDetailParameters

      protected Map<String,Object> createRuleResultDetailParameters(int number)
      Creates the parameter data for the rule result detail.
      Parameters:
      number - matching number
      Returns:
      map of parameter name to value
    • toString

      public String toString()
      Overrides:
      toString in class Object