summaryrefslogtreecommitdiff
path: root/lib/gitlab/ci/config/node/validators.rb
blob: dc9cdb9a2205038fc928b8a8f06662e55f649476 (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
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

          class HashValidator < ActiveModel::EachValidator
            def validate_each(record, attribute, value)
              unless value.is_a?(Hash)
                record.errors.add(attribute, 'should be a configuration entry hash')
              end
            end
          end
        end
      end
    end
  end
end