Sha256: d64eff7154175550c8031c28e30d690b4bffbbfc5a3fa53bb3bde84a8e8dd53a
Contents?: true
Size: 816 Bytes
Versions: 58
Compression:
Stored size: 816 Bytes
Contents
module Katello module Validators class PriorValidator < ActiveModel::Validator def validate(record) #need to ensure that prior #environment already does not have a successor #this is because in v1.0 we want # prior to have only one child (unless its the Library) has_no_prior = true if record.organization has_no_prior = record.organization.kt_environments.reject { |env| env == record || env.prior != record.prior || env.prior == env.organization.library }.empty? end record.errors[:prior] << _("environment can only have one child") unless has_no_prior # only Library can have prior=nil record.errors[:prior] << _("environment required") unless !record.prior.nil? || record.library? end end end end
Version data entries
58 entries across 58 versions & 1 rubygems