diff options
Diffstat (limited to 'app/models/namespace_setting.rb')
-rw-r--r-- | app/models/namespace_setting.rb | 19 |
1 files changed, 19 insertions, 0 deletions
diff --git a/app/models/namespace_setting.rb b/app/models/namespace_setting.rb index 53bfa3d979e..6f31208f28b 100644 --- a/app/models/namespace_setting.rb +++ b/app/models/namespace_setting.rb @@ -3,7 +3,26 @@ class NamespaceSetting < ApplicationRecord belongs_to :namespace, inverse_of: :namespace_settings + validate :default_branch_name_content + validate :allow_mfa_for_group + + NAMESPACE_SETTINGS_PARAMS = [:default_branch_name].freeze + self.primary_key = :namespace_id + + def default_branch_name_content + return if default_branch_name.nil? + + if default_branch_name.blank? + errors.add(:default_branch_name, "can not be an empty string") + end + end + + def allow_mfa_for_group + if namespace&.subgroup? && allow_mfa_for_subgroups == false + errors.add(:allow_mfa_for_subgroups, _('is not allowed since the group is not top-level group.')) + end + end end NamespaceSetting.prepend_if_ee('EE::NamespaceSetting') |