Class: ActiveModel::Validations::CreditCardNumberValidator
- Inherits:
-
EachValidator
- Object
- EachValidator
- ActiveModel::Validations::CreditCardNumberValidator
- Defined in:
- lib/active_model/credit_card_number_validator.rb
Instance Method Summary collapse
- #credit_card_valid?(number, brands = []) ⇒ Boolean
- #validate_each(record, attribute, value) ⇒ Object
Instance Method Details
#credit_card_valid?(number, brands = []) ⇒ Boolean
49 50 51 |
# File 'lib/active_model/credit_card_number_validator.rb', line 49 def credit_card_valid?(number, brands = []) CreditCardValidations::Detector.new(number).valid?(*brands) end |
#validate_each(record, attribute, value) ⇒ Object
45 46 47 |
# File 'lib/active_model/credit_card_number_validator.rb', line 45 def validate_each(record, attribute, value) record.errors.add(attribute, [:message] || :invalid) unless credit_card_valid?(value, extract_brands(record, )) end |