diff options
Diffstat (limited to 'lib/gitlab/config/entry/validators.rb')
-rw-r--r-- | lib/gitlab/config/entry/validators.rb | 12 |
1 files changed, 10 insertions, 2 deletions
diff --git a/lib/gitlab/config/entry/validators.rb b/lib/gitlab/config/entry/validators.rb index 13c6eaf4993..5d2bf3cfebf 100644 --- a/lib/gitlab/config/entry/validators.rb +++ b/lib/gitlab/config/entry/validators.rb @@ -90,14 +90,22 @@ module Gitlab end end - class NestedArrayOfHashesValidator < ArrayOfHashesValidator + class NestedArrayOfHashesOrArraysValidator < ArrayOfHashesValidator include NestedArrayHelpers def validate_each(record, attribute, value) - unless validate_nested_array(value, 1, &method(:validate_array_of_hashes)) + max_level = options.fetch(:max_level, 1) + + unless validate_nested_array(value, max_level, &method(:validate_hash)) record.errors.add(attribute, 'should be an array containing hashes and arrays of hashes') end end + + private + + def validate_hash(value) + value.is_a?(Hash) + end end class ArrayOrStringValidator < ActiveModel::EachValidator |