summaryrefslogtreecommitdiff
path: root/lib/gitlab/ci/config/node/commands.rb
blob: d7657ae314b1776301cb3dc7ab7129da2341e431 (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
28
29
30
31
32
33
module Gitlab
  module Ci
    class Config
      module Node
        ##
        # Entry that represents a job script.
        #
        class Commands < Entry
          include Validatable

          validations do
            include LegacyValidationHelpers

            validate do
              unless string_or_array_of_strings?(config)
                errors.add(:config,
                           'should be a string or an array of strings')
              end
            end

            def string_or_array_of_strings?(field)
              validate_string(field) || validate_array_of_strings(field)
            end
          end

          def value
            Array(@config)
          end
        end
      end
    end
  end
end