Module: Quby::Compiler::DSL::Questions::MinMaxValidations

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

Instance Method Summary collapse

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, 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



67
68
69
70
71
# File 'lib/quby/compiler/dsl/questions/base.rb', line 67

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



61
62
63
64
65
# File 'lib/quby/compiler/dsl/questions/base.rb', line 61

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