diff options
author | Jean-Philippe Lang <jp_lang@yahoo.fr> | 2018-11-28 18:15:34 +0000 |
---|---|---|
committer | Jean-Philippe Lang <jp_lang@yahoo.fr> | 2018-11-28 18:15:34 +0000 |
commit | bee7f2531b170035f037365a474783dd3eb2b22b (patch) | |
tree | 7e535d3ffa4d19c06a16df94f1152c8d7f160a75 /lib | |
parent | 726a6e3c81b629e529963fc4ab6009fc2609bfc0 (diff) | |
download | redmine-bee7f2531b170035f037365a474783dd3eb2b22b.tar.gz redmine-bee7f2531b170035f037365a474783dd3eb2b22b.zip |
Missing validation for custom field formats based on RecordList (#29674).
Patch by Alexander Achenbach.
git-svn-id: http://svn.redmine.org/redmine/trunk@17645 e93f8b46-1217-0410-a6f0-8f06a7374b81
Diffstat (limited to 'lib')
-rw-r--r-- | lib/redmine/field_format.rb | 10 |
1 files changed, 10 insertions, 0 deletions
diff --git a/lib/redmine/field_format.rb b/lib/redmine/field_format.rb index 64fcdc6a4..3878b2dcb 100644 --- a/lib/redmine/field_format.rb +++ b/lib/redmine/field_format.rb @@ -740,6 +740,16 @@ module Redmine options end + def validate_custom_value(custom_value) + values = Array.wrap(custom_value.value).reject {|value| value.to_s == ''} + invalid_values = values - possible_custom_value_options(custom_value).map(&:last) + if invalid_values.any? + [::I18n.t('activerecord.errors.messages.inclusion')] + else + [] + end + end + def order_statement(custom_field) if target_class.respond_to?(:fields_for_order_statement) target_class.fields_for_order_statement(value_join_alias(custom_field)) |