Class: JSONSkooma::Keywords::Validation::MultipleOf

Inherits:
Base
  • Object
show all
Defined in:
lib/json_skooma/keywords/validation/multiple_of.rb

Instance Attribute Summary

Attributes inherited from Base

#json, #parent_schema

Instance Method Summary collapse

Methods inherited from Base

#each_schema, inherited, #initialize, #instance_types, #key, #resolve, set_defaults, #static, value_schema=

Constructor Details

This class inherits a constructor from JSONSkooma::Keywords::Base

Instance Method Details

#evaluate(instance, result) ⇒ Object



12
13
14
15
16
# File 'lib/json_skooma/keywords/validation/multiple_of.rb', line 12

def evaluate(instance, result)
  if BigDecimal(instance.value.to_s).modulo(BigDecimal(json.value.to_s)).nonzero?
    result.failure("The value must be a multiple of #{json.value}")
  end
end