Sha256: 2e3d61f805f731d74ac9c6a0f0839edc38bb79e7ef04ffdd8c403ef95899756f
Contents?: true
Size: 768 Bytes
Versions: 3
Compression:
Stored size: 768 Bytes
Contents
require 'active_model/validator' module KontoAPI class BankAccountValidator < ActiveModel::Validator def validate(record) account_number = record.send(:"#{options[:account_number_field]}") bank_code = record.send(:"#{options[:bank_code_field]}") return true if options[:allow_nil] && (account_number.nil? || bank_code.nil?) record.errors.add(:"#{options[:account_number_field]}", :invalid) unless KontoAPI::valid?( :ktn => account_number, :blz => bank_code ) rescue Timeout::Error => ex case options[:on_timeout] when :fail record.errors.add(:"#{options[:account_number_field]}", :timeout) when :ignore # nop when :retry raise 'not implemented yet' end end end end
Version data entries
3 entries across 3 versions & 1 rubygems