Class: ActiveModel::Validations::DebitcardValidator

Inherits:
EachValidator
  • Object
show all
Defined in:
lib/active_model/validations/debitcard_validator.rb

Instance Method Summary collapse

Instance Method Details

#validate_each(record, attribute, value) ⇒ Object



6
7
8
9
10
11
12
13
14
15
# File 'lib/active_model/validations/debitcard_validator.rb', line 6

def validate_each(record, attribute, value)
  value = trim_number(value)
  if value =~ debitcard_regexes
    record.errors.add(attribute, :is_debitcard || 'is debitcard.')
  end

  if value =~ prepaidcard_regexes
    record.errors.add(attribute, :is_prepaidcard || 'is prepaidcard.')
  end
end