Class: SEPA::LEIValidator

Inherits:
ActiveModel::Validator
  • Object
show all
Defined in:
lib/sepa_rator/validator.rb

Constant Summary collapse

REGEX =

LEIIdentifier (ISO 17442): 18 alphanumeric + 2 check digits

/\A[A-Z0-9]{18}[0-9]{2}\z/

Instance Method Summary collapse

Instance Method Details

#validate(record) ⇒ Object



108
109
110
111
112
113
114
115
116
# File 'lib/sepa_rator/validator.rb', line 108

def validate(record)
  field_name = options[:field_name] || :lei
  value = record.public_send(field_name)

  return unless value
  return if valid_lei?(value.to_s)

  record.errors.add(field_name, :invalid, message: options[:message])
end