diff options
Diffstat (limited to 'app/models')
-rw-r--r-- | app/models/application_setting.rb | 4 | ||||
-rw-r--r-- | app/models/application_setting_implementation.rb | 7 |
2 files changed, 7 insertions, 4 deletions
diff --git a/app/models/application_setting.rb b/app/models/application_setting.rb index 425a0e05c7d..25b81aef45f 100644 --- a/app/models/application_setting.rb +++ b/app/models/application_setting.rb @@ -283,10 +283,6 @@ class ApplicationSetting < ApplicationRecord validates :allowed_key_types, presence: true - repository_storages_weighted_attributes.each do |attribute| - validates attribute, allow_nil: true, numericality: { only_integer: true, greater_than_or_equal_to: 0, less_than_or_equal_to: 100 } - end - validates_each :restricted_visibility_levels do |record, attr, value| value&.each do |level| unless Gitlab::VisibilityLevel.options.value?(level) diff --git a/app/models/application_setting_implementation.rb b/app/models/application_setting_implementation.rb index c489d11d462..73554ee8457 100644 --- a/app/models/application_setting_implementation.rb +++ b/app/models/application_setting_implementation.rb @@ -451,6 +451,13 @@ module ApplicationSettingImplementation invalid = repository_storages_weighted.keys - Gitlab.config.repositories.storages.keys errors.add(:repository_storages_weighted, "can't include: %{invalid_storages}" % { invalid_storages: invalid.join(", ") }) unless invalid.empty? + + repository_storages_weighted.each do |key, val| + next unless val.present? + + errors.add(:"repository_storages_weighted_#{key}", "value must be an integer") unless val.is_a?(Integer) + errors.add(:"repository_storages_weighted_#{key}", "value must be between 0 and 100") unless val.between?(0, 100) + end end def terms_exist |