mirror of
https://github.com/wahyd4/gitlabhq.git
synced 2026-08-11 05:36:07 +10:00
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`
28 lines
531 B
Ruby
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
|