Class: SEPA::MandateIdentifierValidator
- Inherits:
-
ActiveModel::Validator
- Object
- ActiveModel::Validator
- SEPA::MandateIdentifierValidator
- Defined in:
- lib/sepa_rator/validator.rb
Constant Summary collapse
- REGEX =
%r{\A[A-Za-z0-9 +?/:().,'-]{1,35}\z}
Instance Method Summary collapse
Instance Method Details
#validate(record) ⇒ Object
94 95 96 97 98 99 100 101 |
# File 'lib/sepa_rator/validator.rb', line 94 def validate(record) field_name = [:field_name] || :mandate_id value = record.public_send(field_name) return if value.to_s.match?(REGEX) record.errors.add(field_name, :invalid, message: [:message]) end |