demarches-normaliennes/app/validators/iban_validator.rb
2024-08-22 09:26:48 +02:00

13 lines
276 B
Ruby

# frozen_string_literal: true
require 'iban-tools'
class IbanValidator < ActiveModel::Validator
def validate(record)
if record.value.present?
unless IBANTools::IBAN.valid?(record.value)
record.errors.add :value, :invalid_iban
end
end
end
end