2024-04-29 00:17:15 +02:00
|
|
|
# frozen_string_literal: true
|
|
|
|
|
2020-09-22 16:04:57 +02:00
|
|
|
require 'iban-tools'
|
|
|
|
|
|
|
|
class IbanValidator < ActiveModel::Validator
|
|
|
|
def validate(record)
|
|
|
|
if record.value.present?
|
|
|
|
unless IBANTools::IBAN.valid?(record.value)
|
2023-09-19 11:07:50 +02:00
|
|
|
record.errors.add :value, :invalid_iban
|
2020-09-22 16:04:57 +02:00
|
|
|
end
|
|
|
|
end
|
|
|
|
end
|
|
|
|
end
|