Revision 0b5f7acb
Added by Ori Rabin over 7 years ago
app/models/lookup_value.rb | ||
---|---|---|
before_validation :sanitize_match
|
||
|
||
before_validation :validate_and_cast_value, :unless => Proc.new{|p| p.omit }
|
||
validate :validate_value, :ensure_fqdn_exists, :ensure_hostgroup_exists
|
||
validate :validate_value, :ensure_fqdn_exists, :ensure_hostgroup_exists, :ensure_matcher_exists
|
||
|
||
attr_accessor :host_or_hostgroup
|
||
|
||
... | ... | |
matcher
|
||
end
|
||
|
||
def ensure_matcher_exists
|
||
return false if match.blank?
|
||
key_elements = []
|
||
match.split(LookupKey::KEY_DELM).each do |m|
|
||
key_elements << m.split(LookupKey::EQ_DELM).first
|
||
end
|
||
|
||
unless lookup_key.path_elements.include?(key_elements)
|
||
errors.add(:match, _("%{key} does not exist in order field") % { :key => key_elements.join(',') })
|
||
end
|
||
end
|
||
|
||
def skip_strip_attrs
|
||
['value']
|
||
end
|
Also available in: Unified diff
Fixes #17238 - Validates lookup value match exists in key path