Class: SEPA::MandateIdentifierValidator
- Inherits:
-
ActiveModel::Validator
- Object
- ActiveModel::Validator
- SEPA::MandateIdentifierValidator
- Defined in:
- lib/sepa_king/validator.rb
Constant Summary collapse
- REGEX =
%r{\A([A-Za-z0-9]|[+|?|/|\-|:|(|)|.|,|']){1,35}\z}.freeze
Instance Method Summary collapse
Instance Method Details
#validate(record) ⇒ Object
50 51 52 53 54 55 |
# File 'lib/sepa_king/validator.rb', line 50 def validate(record) field_name = [:field_name] || :mandate_id value = record.send(field_name) record.errors.add(field_name, :invalid, message: [:message]) unless value.to_s.match(REGEX) end |