Skip to content

Commit

Permalink
[webui] Show the actual value in the validation error and not the object
Browse files Browse the repository at this point in the history
  • Loading branch information
bgeuken committed Sep 2, 2015
1 parent e3ec17c commit 06570ce
Showing 1 changed file with 5 additions and 5 deletions.
10 changes: 5 additions & 5 deletions src/api/app/models/attrib.rb
Original file line number Diff line number Diff line change
Expand Up @@ -116,11 +116,11 @@ def update_with_associations(values = [], issues = [])

def validate_value_count
if self.attrib_type && self.attrib_type.allowed_values.any?
self.values.each do |value|
allowed_values = self.attrib_type.allowed_values
if allowed_values.none? { |allowed| allowed.value == value.value }
self.errors[:values] << "Value '#{value}' is not allowed. Please use one of: " +
"#{allowed_values.map(&:value).join(', ')}"
self.values.map(&:value).each do |value|
allowed_values = self.attrib_type.allowed_values.map(&:value)
unless allowed_values.include?(value)
self.errors[:values] <<
"Value '#{value}' is not allowed. Please use one of: #{allowed_values.join(', ')}"
end
end
end
Expand Down

0 comments on commit 06570ce

Please sign in to comment.