Class: Braspag::CreditCard::ExpiratorValidator
- Inherits:
-
ActiveModel::EachValidator
- Object
- ActiveModel::EachValidator
- Braspag::CreditCard::ExpiratorValidator
- Defined in:
- lib/cbraspag/payment/credit_card.rb
Instance Method Summary collapse
Instance Method Details
#validate_each(record, attribute, value) ⇒ Object
53 54 55 56 57 58 59 60 61 62 63 64 |
# File 'lib/cbraspag/payment/credit_card.rb', line 53 def validate_each(record, attribute, value) begin year = record.year.try(:to_i) year = "20#{year}".to_i if year && year.to_s.size == 2 month = record.month.try(:to_i) Date.new(year, month) if year && month rescue ArgumentError record.errors.add attribute, "invalid date" end end |