Class: WireClient::IBANValidator
- Inherits:
-
BaseValidator
- Object
- ActiveModel::Validator
- BaseValidator
- WireClient::IBANValidator
- Defined in:
- lib/wire_client/base/validators.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/
Instance Method Summary collapse
Methods inherited from BaseValidator
Instance Method Details
#validate(record) ⇒ Object
68 69 70 71 72 73 74 75 76 |
# File 'lib/wire_client/base/validators.rb', line 68 def validate(record) field_name, value = extract_field_name_value(record) if value.present? unless IBANTools::IBAN.valid?(value) && value.match(REGEX) record.errors.add(field_name, :invalid, message: [:message]) end end end |