lib/devise-security/validators/password_complexity_validator.rb
def validate_each(record, attribute, password)
    return if password.blank?

    options.sort.each do |pattern_name, minimum|
      normalized_option = pattern_name.to_s.singularize.to_sym

      next unless patterns.key?(normalized_option)
      next unless minimum.positive?
      next if password.scan(patterns[normalized_option]).size >= minimum

      record.errors.add(
        attribute,
        :"password_complexity.#{normalized_option}",
        count: minimum
      )
    end
  end
# Validate the complexity of the password. This validation does not check to
# ensure the password is not blank. That is the responsibility of other
# validations. This validator will also ignore any patterns that are not
# explicitly configured to be used or whose minimum limits are less than 1.
#
# @param record [ActiveModel::Model]
# @param attribute [Symbol]
# @param password [String]
Validate the complexity of the password. This validation does not check to
ensure the password is not blank. That is the responsibility of other
validations. This validator will also ignore any patterns that are not
explicitly configured to be used or whose minimum limits are less than 1.
Validate the complexity of the password . This validation does not check to ensure the password is not blank . That is the responsibility of other validations . This validator will also ignore any patterns that are not explicitly configured to be used or whose minimum limits are less than 1 .
def validate_each(record, attribute, password)
    return if password.blank?
    options.sort.each do |pattern_name, minimum|
      normalized_option = pattern_name.to_s.singularize.to_sym
      next unless patterns.key?(normalized_option)
      next unless minimum.positive?
      next if password.scan(patterns[normalized_option]).size >= minimum
      record.errors.add(
        attribute,
        :"password_complexity.#{normalized_option}",
        count: minimum
      )
    end
  end
def validate_each ( record , attribute , password ) return if password . blank? options . sort . each do | pattern_name , minimum | normalized_option = pattern_name . to_s . singularize . to_sym next unless patterns . key? ( normalized_option ) next unless minimum . positive? next if password . scan ( patterns [ normalized_option ] ) . size >= minimum record . errors . add ( attribute , :" password_complexity. #{ normalized_option } " , count : minimum ) end end
Validate the complexity of the password.
Validate the complexity of the password .
record
attribute
password
None