Class: Katello::Validators::RepositoryUniqueAttributeValidator

Inherits:
ActiveModel::EachValidator
  • Object
show all
Defined in:
app/lib/katello/validators/repository_unique_attribute_validator.rb

Instance Method Summary collapse

Instance Method Details

#validate_each(record, attribute, _value) ⇒ Object



4
5
6
7
8
9
10
# File 'app/lib/katello/validators/repository_unique_attribute_validator.rb', line 4

def validate_each(record, attribute, _value)
  unique = !record.exist_for_environment?(record.environment, record.content_view, attribute)

  if !unique && record.send("#{attribute}_changed?")
    record.errors[attribute] << _("has already been taken for this product.")
  end
end