]> source.dussan.org Git - redmine.git/commitdiff
Missing validation for custom field formats based on RecordList (#29674).
authorJean-Philippe Lang <jp_lang@yahoo.fr>
Wed, 28 Nov 2018 18:15:34 +0000 (18:15 +0000)
committerJean-Philippe Lang <jp_lang@yahoo.fr>
Wed, 28 Nov 2018 18:15:34 +0000 (18:15 +0000)
Patch by Alexander Achenbach.

git-svn-id: http://svn.redmine.org/redmine/trunk@17645 e93f8b46-1217-0410-a6f0-8f06a7374b81

lib/redmine/field_format.rb

index 64fcdc6a4ea0aa8cdc0155078c153d61573c19be..3878b2dcb861eee90b14ff0869a89d843599864f 100644 (file)
@@ -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))