diff options
author | GitLab Bot <gitlab-bot@gitlab.com> | 2020-12-17 14:59:07 +0300 |
---|---|---|
committer | GitLab Bot <gitlab-bot@gitlab.com> | 2020-12-17 14:59:07 +0300 |
commit | 8b573c94895dc0ac0e1d9d59cf3e8745e8b539ca (patch) | |
tree | 544930fb309b30317ae9797a9683768705d664c4 /lib/gitlab/config | |
parent | 4b1de649d0168371549608993deac953eb692019 (diff) |
Add latest changes from gitlab-org/gitlab@13-7-stable-eev13.7.0-rc42
Diffstat (limited to 'lib/gitlab/config')
-rw-r--r-- | lib/gitlab/config/entry/validators.rb | 26 |
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 |