Welcome to mirror list, hosted at ThFree Co, Russian Federation.

gitlab.com/gitlab-org/gitlab-foss.git - Unnamed repository; edit this file 'description' to name the repository.
summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
Diffstat (limited to 'lib/gitlab/config/entry/validators.rb')
-rw-r--r--lib/gitlab/config/entry/validators.rb26
1 files changed, 26 insertions, 0 deletions
diff --git a/lib/gitlab/config/entry/validators.rb b/lib/gitlab/config/entry/validators.rb
index 2a386657e0b..88786ed82ff 100644
--- a/lib/gitlab/config/entry/validators.rb
+++ b/lib/gitlab/config/entry/validators.rb
@@ -134,6 +134,16 @@ module Gitlab
end
end
+ class HashOrBooleanValidator < ActiveModel::EachValidator
+ include LegacyValidationHelpers
+
+ def validate_each(record, attribute, value)
+ unless value.is_a?(Hash) || validate_boolean(value)
+ record.errors.add(attribute, 'should be a hash or a boolean value')
+ end
+ end
+ end
+
class KeyValidator < ActiveModel::EachValidator
include LegacyValidationHelpers
@@ -158,6 +168,22 @@ module Gitlab
end
end
+ class ArrayOfIntegersOrIntegerValidator < ActiveModel::EachValidator
+ include LegacyValidationHelpers
+
+ def validate_each(record, attribute, value)
+ unless validate_integer(value) || validate_array_of_integers(value)
+ record.errors.add(attribute, 'should be an array of integers or an integer')
+ end
+ end
+
+ private
+
+ def validate_array_of_integers(values)
+ values.is_a?(Array) && values.all? { |value| validate_integer(value) }
+ end
+ end
+
class RegexpValidator < ActiveModel::EachValidator
include LegacyValidationHelpers