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