Class: SEPA::IBANValidator
- Inherits:
-
ActiveModel::Validator
- Object
- ActiveModel::Validator
- SEPA::IBANValidator
- Defined in:
- lib/sepa_king/validator.rb
Constant Summary collapse
- REGEX =
IBAN2007Identifier (taken from schema)
/\A[A-Z]{2,2}[0-9]{2,2}[a-zA-Z0-9]{1,30}\z/.freeze
Instance Method Summary collapse
Instance Method Details
#validate(record) ⇒ Object
8 9 10 11 12 13 |
# File 'lib/sepa_king/validator.rb', line 8 def validate(record) field_name = [:field_name] || :iban value = record.send(field_name).to_s record.errors.add(field_name, :invalid, message: [:message]) unless value.match(REGEX) end |