Class: SimpleJSONSchema::Validators::Numeric
- Defined in:
- lib/simple_json_schema/validators/numeric.rb
Instance Method Summary collapse
Methods inherited from Base
Instance Method Details
#validate(scope) ⇒ Object
6 7 8 9 10 11 12 13 14 15 16 17 18 19 |
# File 'lib/simple_json_schema/validators/numeric.rb', line 6 def validate(scope) value = scope.value Checker.at_value(scope, :maximum, :>) Checker.at_value(scope, :minimum, :<) Checker.at_value(scope, :exclusiveMaximum, :>=) Checker.at_value(scope, :exclusiveMinimum, :<=) multiple_of = scope[:multipleOf] return unless multiple_of quotient = value / multiple_of.to_f scope.error(:multipleOf) unless quotient.floor == quotient end |