Class: ActiveModel::Validations::CreditCardValidator
- Inherits:
-
EachValidator
- Object
- EachValidator
- ActiveModel::Validations::CreditCardValidator
- Defined in:
- lib/active_validators/active_model/validations/credit_card_validator.rb
Defined Under Namespace
Classes: ActiveCreditCardBrand
Instance Method Summary collapse
Instance Method Details
#validate_each(record, attribute, value) ⇒ Object
6 7 8 9 10 |
# File 'lib/active_validators/active_model/validations/credit_card_validator.rb', line 6 def validate_each(record, attribute, value) brand = .fetch(:type, :any) brands = (brand == :any ? [] : Array.wrap(brand)) record.errors.add(attribute) if value.blank? || !ActiveCreditCardBrand.new(value).valid?(*brands) end |