Module: Quby::Questionnaires::DSL::Questions::MinMaxValidations

Included in:
DateQuestionBuilder, FloatQuestionBuilder, IntegerQuestionBuilder
Defined in:
lib/quby/questionnaires/dsl/questions/base.rb

Instance Method Summary collapse

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, options = {})
  subtype = @question.type == :date ? :date : :number
  @question.validations ||= []
  @question.validations << {type: :minimum, value: range.first, subtype: subtype}.reverse_merge(options)
  @question.validations << {type: :maximum, value: range.last, subtype: subtype}.reverse_merge(options)
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, options = {})
  subtype = @question.type == :date ? :date : :number
  @question.validations ||= []
  @question.validations << {type: :maximum, value: value, subtype: subtype}.reverse_merge(options)
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, options = {})
  subtype = @question.type == :date ? :date : :number
  @question.validations ||= []
  @question.validations << {type: :minimum, value: value, subtype: subtype}.reverse_merge(options)
end