module ParamsChecker::Helper
Public Instance Methods
check_type( type: '', values: [] )
click to toggle source
# File lib/params_checker/helper.rb, line 7 def check_type( type: '', values: [] ) case type when 'integer' raise "This field's type must be integer." if values.any? { |value| !value.is_a?(Integer) } when 'numeric' raise "This field's type must be numeric." if values.any? { |value| !value.is_a?(Numeric) } when 'boolean' raise "This field's type must be boolean." if values.any? { |value| !value.in? [true, false] } end end