com.github.fge.jsonschema.main
Class JsonValidator

java.lang.Object
  extended by com.github.fge.jsonschema.main.JsonValidator

@Immutable
public final class JsonValidator
extends Object

A generic schema/instance validator

One such instance exists per JsonSchemaFactory. In fact, you have to go through a factory to obtain an instance.

This class is also responsible for building JsonSchema instances.

See Also:
JsonSchemaFactory.getValidator()

Method Summary
 ProcessingReport validate(JsonNode schema, JsonNode instance)
          Validate a schema/instance pair, "fast" version
 ProcessingReport validate(JsonNode schema, JsonNode instance, boolean deepCheck)
          Validate a schema/instance pair
 ProcessingReport validateUnchecked(JsonNode schema, JsonNode instance)
          Validate a schema/instance pair (unchecked mode), "fast" version
 ProcessingReport validateUnchecked(JsonNode schema, JsonNode instance, boolean deepCheck)
          Validate a schema/instance pair (unchecked mode)
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Method Detail

validate

public ProcessingReport validate(JsonNode schema,
                                 JsonNode instance,
                                 boolean deepCheck)
                          throws ProcessingException
Validate a schema/instance pair

The third boolean argument instructs the validator as to whether it should validate children even if the container (array or object) fails to validate.

Parameters:
schema - the schema
instance - the instance
deepCheck - see description
Returns:
a validation report
Throws:
ProcessingException - an exception occurred during validation
NullPointerException - the schema or instance is null
Since:
2.1.8

validate

public ProcessingReport validate(JsonNode schema,
                                 JsonNode instance)
                          throws ProcessingException
Validate a schema/instance pair, "fast" version

This calls validate(JsonNode, JsonNode, boolean) with false as the third argument.

Parameters:
schema - the schema
instance - the instance
Returns:
a validation report
Throws:
ProcessingException - an exception occurred during validation
NullPointerException - the schema or instance is null

validateUnchecked

public ProcessingReport validateUnchecked(JsonNode schema,
                                          JsonNode instance,
                                          boolean deepCheck)
Validate a schema/instance pair (unchecked mode)

The third boolean argument instructs the validator as to whether it should validate children even if the container (array or object) fails to validate.

The same warnings as described in JsonSchema.validateUnchecked(JsonNode) apply

Parameters:
schema - the schema
instance - the instance
deepCheck - see description
Returns:
a validation report
Throws:
NullPointerException - the schema or instance is null
Since:
2.1.8

validateUnchecked

public ProcessingReport validateUnchecked(JsonNode schema,
                                          JsonNode instance)
Validate a schema/instance pair (unchecked mode), "fast" version

This calls validateUnchecked(JsonNode, JsonNode, boolean) with false as a third argument.

The same warnings as described in JsonSchema.validateUnchecked(JsonNode) apply

Parameters:
schema - the schema
instance - the instance
Returns:
a validation report
Throws:
NullPointerException - the schema or instance is null