Sha256: 1066dfb8f0b36d7f619fe62036e8d5df836dc0740aaf08a08e252ffe504a8ceb
Contents?: true
Size: 714 Bytes
Versions: 12
Compression:
Stored size: 714 Bytes
Contents
module Katello module Validators class ProductUniqueAttributeValidator < ActiveModel::EachValidator def validate_each(record, attribute, value) unique = self.unique_attribute?(record, attribute, value) unless unique record.errors[attribute] << _("has already been taken for a product in this organization.") end end def unique_attribute?(record, attribute, value) unique = true if record.provider && !record.provider.redhat_provider? && record.send("#{attribute}_changed?") && Product.in_org(record.provider.organization).where(attribute => value).exists? unique = false end unique end end end end
Version data entries
12 entries across 12 versions & 1 rubygems