Class: UniquenessAmongSiblingsValidator

Inherits:
ActiveModel::EachValidator
  • Object
show all
Defined in:
lib/droom/validators.rb

Instance Method Summary collapse

Instance Method Details

#validate_each(record, attribute, value) ⇒ Object



8
9
10
# File 'lib/droom/validators.rb', line 8

def validate_each(record, attribute, value)
  record.errors.add(attribute, :taken) if record.siblings.send(:"find_by_#{attribute}", value)
end