Sha256: 48e0855d00df1159905a237be91cb961748b4fe040195265ddb7737e189e72f7

Contents?: true

Size: 333 Bytes

Versions: 3

Compression:

Stored size: 333 Bytes

Contents

class IbanValidator < ActiveModel::EachValidator

  def validate_each(record, attribute, value)
    record_error(record, attribute, value) unless BankValidator::Iban.new(value).valid?
  end
  

  private
  
  def record_error(record, attribute, value)
    record.errors.add(attribute, (options[:message] || :invalid_iban))
  end
end

Version data entries

3 entries across 3 versions & 1 rubygems

Version Path
bank-validator-0.3.2 lib/active_model/iban_validator.rb
bank-validator-0.3.1 lib/active_model/iban_validator.rb
bank-validator-0.3.0 lib/active_model/iban_validator.rb