Class: ActiveModel::Validations::BankFieldValidator
- Inherits:
-
EachValidator
- Object
- EachValidator
- ActiveModel::Validations::BankFieldValidator
- Defined in:
- lib/swiss_bank_validator/validates_bank_field_of.rb
Instance Method Summary collapse
Instance Method Details
#validate_each(record, attribute, value) ⇒ Object
6 7 8 9 10 11 12 13 14 15 16 17 |
# File 'lib/swiss_bank_validator/validates_bank_field_of.rb', line 6 def validate_each(record, attribute, value) return if value.blank? && [:allow_blank] return if value.nil? && [:allow_nil] return if value.to_s =~ SwissBankValidator::BANK_REGEX record.errors.add( attribute, :invalid_bank_field, message: [:message] ) end |