Class: SEPA::BICValidator
- Inherits:
-
ActiveModel::Validator
- Object
- ActiveModel::Validator
- SEPA::BICValidator
- Defined in:
- lib/sepa_rator/validator.rb
Constant Summary collapse
- V03_REGEX =
AnyBICIdentifier (pain.001.001.03 and earlier schemas)
/\A[A-Z]{6,6}[A-Z2-9][A-NP-Z0-9]([A-Z0-9]{3,3}){0,1}\z/- V09_REGEX =
BICFIDec2014Identifier (pain.001.001.09 / .13 and pain.008.001.08 / .12)
/\A[A-Z0-9]{4,4}[A-Z]{2,2}[A-Z0-9]{2,2}([A-Z0-9]{3,3}){0,1}\z/- REGEX =
V03_REGEX
Instance Method Summary collapse
Instance Method Details
#validate(record) ⇒ Object
47 48 49 50 51 52 53 54 55 |
# File 'lib/sepa_rator/validator.rb', line 47 def validate(record) field_name = [:field_name] || :bic value = record.public_send(field_name) return unless value return if value.to_s.match?(V03_REGEX) || value.to_s.match?(V09_REGEX) record.errors.add(field_name, :invalid, message: [:message]) end |