Files
gitlabhq/lib/gitlab/ci/config/node/validator.rb
T
Grzegorz Bizon d9ca84015c Add first custom validator for new ci config
This follows a standard `ActiveModel` pattern of creating a custom
validators. We use `ActiveModel::EachValidator` here that reuses methods
provided by `LegacyValidationHelpers`.

We will remove `LegacyValidationHelpers` on some point in the future, at
the later stages of CI configuration refactoring. It may be possible
to rewrite custom validators to use format like:

`validates :config, array_of: String`
2016-06-17 12:06:48 +02:00

28 lines
531 B
Ruby

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 full_errors
errors.full_messages.map do |error|
"#{@node.key} #{error}".humanize
end
end
def self.name
'Validator'
end
end
end
end
end
end