Module: Quby::Questionnaires::DSL::Questions::MinMaxValidations
- Included in:
- DateQuestionBuilder, FloatQuestionBuilder, IntegerQuestionBuilder
- Defined in:
- lib/quby/questionnaires/dsl/questions/base.rb
Instance Method Summary collapse
- #validates_in_range(range, options = {}) ⇒ Object
- #validates_maximum(value, options = {}) ⇒ Object
- #validates_minimum(value, options = {}) ⇒ Object
Instance Method Details
#validates_in_range(range, options = {}) ⇒ Object
75 76 77 78 79 80 |
# File 'lib/quby/questionnaires/dsl/questions/base.rb', line 75 def validates_in_range(range, = {}) subtype = @question.type == :date ? :date : :number @question.validations ||= [] @question.validations << {type: :minimum, value: range.first, subtype: subtype}.reverse_merge() @question.validations << {type: :maximum, value: range.last, subtype: subtype}.reverse_merge() end |
#validates_maximum(value, options = {}) ⇒ Object
69 70 71 72 73 |
# File 'lib/quby/questionnaires/dsl/questions/base.rb', line 69 def validates_maximum(value, = {}) subtype = @question.type == :date ? :date : :number @question.validations ||= [] @question.validations << {type: :maximum, value: value, subtype: subtype}.reverse_merge() end |
#validates_minimum(value, options = {}) ⇒ Object
63 64 65 66 67 |
# File 'lib/quby/questionnaires/dsl/questions/base.rb', line 63 def validates_minimum(value, = {}) subtype = @question.type == :date ? :date : :number @question.validations ||= [] @question.validations << {type: :minimum, value: value, subtype: subtype}.reverse_merge() end |