2016-06-16 08:16:33 -04:00
|
|
|
module Gitlab
|
|
|
|
module Ci
|
|
|
|
class Config
|
2016-11-14 04:31:45 -05:00
|
|
|
module Entry
|
2016-06-16 08:16:33 -04:00
|
|
|
class Validator < SimpleDelegator
|
2016-06-17 03:33:32 -04:00
|
|
|
include ActiveModel::Validations
|
2016-11-14 04:31:45 -05:00
|
|
|
include Entry::Validators
|
2016-06-17 03:33:32 -04:00
|
|
|
|
2016-11-14 04:31:45 -05:00
|
|
|
def initialize(entry)
|
|
|
|
super(entry)
|
|
|
|
@entry = entry
|
2016-06-16 08:16:33 -04:00
|
|
|
end
|
|
|
|
|
2016-06-23 07:51:34 -04:00
|
|
|
def messages
|
2016-06-16 08:16:33 -04:00
|
|
|
errors.full_messages.map do |error|
|
2016-06-29 03:39:04 -04:00
|
|
|
"#{location} #{error}".downcase
|
2016-06-16 08:16:33 -04:00
|
|
|
end
|
|
|
|
end
|
|
|
|
|
|
|
|
def self.name
|
|
|
|
'Validator'
|
|
|
|
end
|
2016-06-29 03:10:23 -04:00
|
|
|
|
|
|
|
private
|
|
|
|
|
|
|
|
def location
|
2016-06-29 03:39:04 -04:00
|
|
|
predecessors = ancestors.map(&:key).compact
|
2016-07-14 07:14:09 -04:00
|
|
|
predecessors.append(key_name).join(':')
|
|
|
|
end
|
|
|
|
|
|
|
|
def key_name
|
2016-07-18 09:38:06 -04:00
|
|
|
if key.blank?
|
2016-11-14 04:31:45 -05:00
|
|
|
@entry.class.name.demodulize.underscore.humanize
|
2016-07-14 07:14:09 -04:00
|
|
|
else
|
|
|
|
key
|
|
|
|
end
|
2016-06-29 03:10:23 -04:00
|
|
|
end
|
2016-06-16 08:16:33 -04:00
|
|
|
end
|
|
|
|
end
|
|
|
|
end
|
|
|
|
end
|
|
|
|
end
|