Class: OneOfManyValidator

Inherits:
ActiveModel::Validator
  • Object
show all
Defined in:
lib/one_of_many_validator.rb

Instance Method Summary collapse

Instance Method Details

#validate(record) ⇒ Object



4
5
6
7
8
# File 'lib/one_of_many_validator.rb', line 4

def validate(record)
  present_fields = fields.reject { |field| record.attributes[field].blank? }

  record.errors.add(:base, error_type) if present_fields.blank?
end