Skip to content

Move allowlist custom validation method to a concern

Eugie Limpin requested to merge allowlist_validator_concern into master

What does this MR do and why?

Move allowlist custom validation method from ApplicationSetting to a concern so it can be reused in other models.

Before

# ee/app/models/ee/application_setting.rb
validates :git_rate_limit_users_allowlist, length: { maximum: 100 }, allow_nil: false
# custom validation that can only be used in this model      
validate :check_git_rate_limit_users_allowlist

After

# ee/app/models/ee/application_setting.rb
validates :git_rate_limit_users_allowlist, allowlist: true, # other validations 

# Now we can also do

# ee/app/models/ee/other_model.rb
validates :other_allowlist, allowlist: true, # other validations 

This supports work that is being done in https://gitlab.com/gitlab-org/modelops/anti-abuse/team-tasks/-/issues/36

MR acceptance checklist

This checklist encourages us to confirm any changes have been analyzed to reduce risks in quality, performance, reliability, security, and maintainability.

Edited by Eugie Limpin

Merge request reports

Loading