Class: ActiveRecordSurvey::NodeValidation::MaximumValue
- Inherits:
-
ActiveRecordSurvey::NodeValidation
- Object
- ActiveRecord::Base
- ActiveRecordSurvey::NodeValidation
- ActiveRecordSurvey::NodeValidation::MaximumValue
- Defined in:
- lib/active_record_survey/node_validation/maximum_value.rb
Overview
Ensure the instance_node has a value less than the maximum
Instance Method Summary collapse
-
#validate_instance_node(instance_node, answer_node = nil) ⇒ Object
Validate the instance_node value is less than the maximum.
Methods inherited from ActiveRecordSurvey::NodeValidation
Instance Method Details
#validate_instance_node(instance_node, answer_node = nil) ⇒ Object
Validate the instance_node value is less than the maximum
5 6 7 8 9 10 11 |
# File 'lib/active_record_survey/node_validation/maximum_value.rb', line 5 def validate_instance_node(instance_node, answer_node = nil) is_valid = (!instance_node.value.to_s.empty? && instance_node.value.to_f <= self.value.to_f) instance_node.errors[:base] << { :nodes => { answer_node.id => ["MAXIMUM_VALUE"] } } if !is_valid is_valid end |