mirror of
https://github.com/internetee/registry.git
synced 2025-07-31 23:16:23 +02:00
Story#107192666 - validation for settings that DS data allowed and Allow key data cannot be both true
This commit is contained in:
parent
fd4b2debb2
commit
035111e130
3 changed files with 26 additions and 6 deletions
|
@ -6,4 +6,18 @@ class Setting < RailsSettings::CachedSettings
|
|||
Rails.cache.delete_matched('settings:.*')
|
||||
STDOUT << "#{Time.zone.now.utc} - Settings cache cleared\n"
|
||||
end
|
||||
|
||||
|
||||
# cannot do instance validation because CachedSetting use save!
|
||||
def self.params_errors(params)
|
||||
errors = {}
|
||||
# DS data allowed and Allow key data cannot be both true
|
||||
if !!params["key_data_allowed"] && params["key_data_allowed"] == params["ds_data_allowed"]
|
||||
msg = "#{I18n.t(:key_data_allowed)} and #{I18n.t(:ds_data_with_key_allowed)} cannot be both true"
|
||||
errors["key_data_allowed"] = msg
|
||||
errors["ds_data_allowed"] = msg
|
||||
end
|
||||
|
||||
return errors
|
||||
end
|
||||
end
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue