summaryrefslogtreecommitdiff
path: root/lib/gitlab/config/entry/validators.rb
diff options
context:
space:
mode:
Diffstat (limited to 'lib/gitlab/config/entry/validators.rb')
-rw-r--r--lib/gitlab/config/entry/validators.rb17
1 files changed, 8 insertions, 9 deletions
diff --git a/lib/gitlab/config/entry/validators.rb b/lib/gitlab/config/entry/validators.rb
index 88786ed82ff..8120f2c1243 100644
--- a/lib/gitlab/config/entry/validators.rb
+++ b/lib/gitlab/config/entry/validators.rb
@@ -268,17 +268,16 @@ module Gitlab
end
end
- class StringOrNestedArrayOfStringsValidator < NestedArrayOfStringsValidator
- def validate_each(record, attribute, value)
- unless validate_string_or_nested_array_of_strings(value)
- record.errors.add(attribute, 'should be a string or an array containing strings and arrays of strings')
- end
- end
+ class StringOrNestedArrayOfStringsValidator < ActiveModel::EachValidator
+ include LegacyValidationHelpers
+ include NestedArrayHelpers
- private
+ def validate_each(record, attribute, value)
+ max_level = options.fetch(:max_level, 1)
- def validate_string_or_nested_array_of_strings(values)
- validate_string(values) || validate_nested_array_of_strings(values)
+ unless validate_string(value) || validate_nested_array(value, max_level, &method(:validate_string))
+ record.errors.add(attribute, "should be a string or a nested array of strings up to #{max_level} levels deep")
+ end
end
end