class SPS::CreditorIdentifierValidator
Constants
- REGEX
Public Instance Methods
valid?(creditor_identifier)
click to toggle source
# File lib/sps_king/validator.rb, line 45 def valid?(creditor_identifier) if ok = creditor_identifier.to_s.match(REGEX) # In Germany, the identifier has to be exactly 18 chars long if creditor_identifier[0..1].match(/DE/i) ok = creditor_identifier.length == 18 end end ok end
validate(record)
click to toggle source
# File lib/sps_king/validator.rb, line 36 def validate(record) field_name = options[:field_name] || :creditor_identifier value = record.send(field_name) unless valid?(value) record.errors.add(field_name, :invalid, message: options[:message]) end end