debian-mirror-gitlab/lib/gitlab/ci/config/node/validator.rb

43 lines
869 B
Ruby
Raw Normal View History

2016-08-24 12:49:21 +05:30
module Gitlab
module Ci
class Config
module Node
class Validator < SimpleDelegator
include ActiveModel::Validations
include Node::Validators
def initialize(node)
super(node)
@node = node
end
def messages
errors.full_messages.map do |error|
"#{location} #{error}".downcase
end
end
def self.name
'Validator'
end
private
def location
predecessors = ancestors.map(&:key).compact
2016-09-13 17:45:13 +05:30
predecessors.append(key_name).join(':')
end
def key_name
if key.blank?
@node.class.name.demodulize.underscore.humanize
else
key
end
2016-08-24 12:49:21 +05:30
end
end
end
end
end
end