lib/jddf/validator.rb
# Validate a JDDF schema against a JSON instance.
#
# The precise rules of validation for this method are defined formally by
# the JDDF specification, and this method follows those rules exactly,
# assuming that +instance+ is the result of calling +JSON#parse+ using the
# standard library's +JSON+ module.
#
# @param schema [Schema] the schema to validate against
#
# @param instance [Object] the input ("instance") to validate
#
# @raise [MaxDepthExceededError} if {max_depth} is exceeded.
#
# @return [Array] an array of {ValidationError}
Validate a JDDF schema against a JSON instance.
Validate a JDDF schema against a JSON instance .
def validate(schema, instance)
      vm = VM.new
      vm.max_depth = max_depth
      vm.max_errors = max_errors
      vm.root_schema = schema
      vm.instance_tokens = []
      vm.schema_tokens = [[]]
      vm.errors = []
      begin
        vm.validate(schema, instance)
      rescue MaxErrorsError 
      end
      vm.errors
    end
def validate ( schema , instance ) vm = VM . new vm . max_depth = max_depth vm . max_errors = max_errors vm . root_schema = schema vm . instance_tokens = [ ] vm . schema_tokens = [ [ ] ] vm . errors = [ ] begin vm . validate ( schema , instance ) rescue MaxErrorsError end vm . errors end
Validate a JDDF schema against a JSON instance.
Validate a JDDF schema against a JSON instance .
# rubocop:disable Lint/HandleExceptions # There is nothing to do here. MaxErrorsError is just a circuit-breaker.
an array of {ValidationError}
an array of { ValidationError }
Array
[MaxDepthExceededError} if {max_depth} is exceeded.
[ MaxDepthExceededError } if { max_depth } is exceeded .
schema
the schema to validate against
the schema to validate against
instance
the input ("instance") to validate
the input ( " instance " ) to validate