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}
Instance Method Summary collapse
Instance Method Details
#validate(record) ⇒ Object
64 65 66 67 68 69 70 71 |
# File 'lib/sepa_king/validator.rb', line 64 def validate(record) field_name = [:field_name] || :mandate_id value = record.send(field_name) unless value.to_s.match?(REGEX) record.errors.add(field_name, :invalid, message: [:message]) end end |