Skip to content

OpenProject is the leading open source project management software for product, project and portfolio management. A powerful Jira alternative with agile planning, issue tracking, roadmaps, Gantt charts, time tracking, collaboration features, and more. Available on premises or in the cloud. ⭐ Star us on GitHub

Make #valid_attribute? run attr. validations only

Alexander Brandon Coles6764afda874f
diff --git a/app/models/application_record.rb b/app/models/application_record.rb
index 9e8e75ac31f..b32fff78d3d 100644
--- a/app/models/application_record.rb
+++ b/app/models/application_record.rb
@@ -43,7 +43,12 @@ class ApplicationRecord < ActiveRecord::Base
##
# Returns whether the given attribute is free of errors
def valid_attribute?(attribute)
- valid? # Ensure validations have run
+ errors.clear
+
+ # run validations for specified attribute only.
+ self.class.validators_on(attribute).each do |validator|
+ validator.validate_each(self, attribute, public_send(attribute))
+ end
errors[attribute].empty?
end