class ActiveModel::Validations::IbanValidator

Public Instance Methods

validate_each(record, attribute, value) click to toggle source
# File lib/active_model/validations/iban_validator.rb, line 11
def validate_each(record, attribute, value)
  return unless value.present?

  if !IbanBic.parse(value)
    record.errors.add(attribute, :invalid_format)
  elsif !IbanBic.valid_check?(value)
    record.errors.add(attribute, :invalid_check)
  elsif !IbanBic.valid_country_check?(value)
    record.errors.add(attribute, :invalid_country_check)
  elsif options[:tags] && !IbanBic.has_tags?(value, options[:tags])
    record.errors.add(attribute, :invalid_tag)
  end
end