Sha256: 160a76be0155e316b4c270c7522f243ea04b20397a88287f1d47fdabee5586a9

Contents?: true

Size: 434 Bytes

Versions: 35

Compression:

Stored size: 434 Bytes

Contents

# frozen_string_literal: true

class MiniDefender::Rules::ExpiryMonth < MiniDefender::Rule
  def self.signature
    'expiry_month'
  end

  def coerce(value)
    value.to_s.rjust(2, '0')
  end

  def passes?(attribute, value, validator)
    return false unless value.to_s.match?(/^\d{1,2}$/)

    value = value.to_i
    value >= 1 && value <= 12
  end

  def message(attribute, value, validator)
    'Invalid expiry month.'
  end
end

Version data entries

35 entries across 35 versions & 1 rubygems

Version Path
mini_defender-0.6.8 lib/mini_defender/rules/expiry_month.rb
mini_defender-0.6.7 lib/mini_defender/rules/expiry_month.rb
mini_defender-0.6.5 lib/mini_defender/rules/expiry_month.rb
mini_defender-0.6.4 lib/mini_defender/rules/expiry_month.rb
mini_defender-0.6.3 lib/mini_defender/rules/expiry_month.rb
mini_defender-0.6.2 lib/mini_defender/rules/expiry_month.rb
mini_defender-0.6.1 lib/mini_defender/rules/expiry_month.rb
mini_defender-0.6.0 lib/mini_defender/rules/expiry_month.rb
mini_defender-0.5.8 lib/mini_defender/rules/expiry_month.rb
mini_defender-0.5.7 lib/mini_defender/rules/expiry_month.rb
mini_defender-0.5.6 lib/mini_defender/rules/expiry_month.rb
mini_defender-0.5.5 lib/mini_defender/rules/expiry_month.rb
mini_defender-0.5.4 lib/mini_defender/rules/expiry_month.rb
mini_defender-0.5.3 lib/mini_defender/rules/expiry_month.rb
mini_defender-0.5.2 lib/mini_defender/rules/expiry_month.rb
mini_defender-0.5.1 lib/mini_defender/rules/expiry_month.rb
mini_defender-0.5.0 lib/mini_defender/rules/expiry_month.rb
mini_defender-0.4.1 lib/mini_defender/rules/expiry_month.rb
mini_defender-0.4.0 lib/mini_defender/rules/expiry_month.rb
mini_defender-0.3.14 lib/mini_defender/rules/expiry_month.rb