com.github.fge.jsonschema.main
Class JsonSchema

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

@Immutable
public final class JsonSchema
extends Object

Single-schema instance validator

This is the class you will use the most often. It is, in essence, a JsonValidator initialized with a single JSON Schema. Note however that this class still retains the ability to resolve JSON References.

It has no public constructors: you should use the appropriate methods in JsonSchemaFactory to obtain an instance of this class.


Method Summary
 ProcessingReport validate(JsonNode instance)
          Validate an instance and return a processing report
 ProcessingReport validate(JsonNode instance, boolean deepCheck)
          Validate an instance and return a processing report
 ProcessingReport validateUnchecked(JsonNode instance)
          Validate an instance and return a processing report (unchecked version)
 ProcessingReport validateUnchecked(JsonNode instance, boolean deepCheck)
          Validate an instance and return a processing report (unchecked version)
 boolean validInstance(JsonNode instance)
          Check whether an instance is valid against this schema
 boolean validInstanceUnchecked(JsonNode instance)
          Check whether an instance is valid against this schema (unchecked version)
 
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 instance,
                                 boolean deepCheck)
                          throws ProcessingException
Validate an instance and return a processing report

Parameters:
instance - the instance to validate
deepCheck - validate children even if container (array, object) is invalid
Returns:
a processing report
Throws:
ProcessingException - a processing error occurred during validation
Since:
2.1.8
See Also:
JsonValidator.validate(JsonNode, JsonNode, boolean)

validate

public ProcessingReport validate(JsonNode instance)
                          throws ProcessingException
Validate an instance and return a processing report

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

Parameters:
instance - the instance to validate
Returns:
a processing report
Throws:
ProcessingException - a processing error occurred during validation

validateUnchecked

public ProcessingReport validateUnchecked(JsonNode instance,
                                          boolean deepCheck)
Validate an instance and return a processing report (unchecked version)

Unchecked validation means that conditions which would normally cause the processing to stop with an exception are instead inserted into the resulting report.

Warning: this means that anomalous events like an unresolvable JSON Reference, or an invalid schema, are masked!

Parameters:
instance - the instance to validate
deepCheck - validate children even if container (array, object) is invalid
Returns:
a report (a ListProcessingReport if an exception was thrown during processing)
Since:
2.1.8
See Also:
ProcessingResult.uncheckedResult(Processor, ProcessingReport, MessageProvider), JsonValidator.validate(JsonNode, JsonNode, boolean)

validateUnchecked

public ProcessingReport validateUnchecked(JsonNode instance)
Validate an instance and return a processing report (unchecked version)

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

Parameters:
instance - the instance to validate
Returns:
a report (a ListProcessingReport if an exception was thrown during processing)

validInstance

public boolean validInstance(JsonNode instance)
                      throws ProcessingException
Check whether an instance is valid against this schema

Parameters:
instance - the instance
Returns:
true if the instance is valid
Throws:
ProcessingException - an error occurred during processing

validInstanceUnchecked

public boolean validInstanceUnchecked(JsonNode instance)
Check whether an instance is valid against this schema (unchecked version)

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

Parameters:
instance - the instance to validate
Returns:
true if the instance is valid