Module: Quby::Compiler::DSL::Questions::MinMaxValidations
- Included in:
- DateQuestionBuilder, FloatQuestionBuilder, IntegerQuestionBuilder
- Defined in:
- lib/quby/compiler/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
73 74 75 76 77 78 |
# File 'lib/quby/compiler/dsl/questions/base.rb', line 73 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
67 68 69 70 71 |
# File 'lib/quby/compiler/dsl/questions/base.rb', line 67 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
61 62 63 64 65 |
# File 'lib/quby/compiler/dsl/questions/base.rb', line 61 def validates_minimum(value, = {}) subtype = @question.type == :date ? :date : :number @question.validations ||= [] @question.validations << {type: :minimum, value: value, subtype: subtype}.reverse_merge() end |