mirror of
https://github.com/wahyd4/gitlabhq.git
synced 2026-08-13 22:59:19 +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`
20 lines
477 B
Ruby
20 lines
477 B
Ruby
module Gitlab
|
|
module Ci
|
|
class Config
|
|
module Node
|
|
module Validators
|
|
class ArrayOfStringsValidator < ActiveModel::EachValidator
|
|
include LegacyValidationHelpers
|
|
|
|
def validate_each(record, attribute, value)
|
|
unless validate_array_of_strings(value)
|
|
record.errors.add(attribute, 'should be an array of strings')
|
|
end
|
|
end
|
|
end
|
|
end
|
|
end
|
|
end
|
|
end
|
|
end
|