@Immutable public final class JsonSchemaFactory extends Object implements com.github.fge.jsonschema.util.Frozen<JsonSchemaFactoryBuilder>
From an instance of this factory, you can obtain the following:
SyntaxValidator
, to validate schemas;JsonValidator
, to validate an instance against a schema;
JsonSchema
, to validate instances against a fixed schema.
JsonSchemaFactoryBuilder
Modifier and Type | Method and Description |
---|---|
static JsonSchemaFactory |
byDefault()
Return a default factory
|
JsonSchema |
getJsonSchema(com.fasterxml.jackson.databind.JsonNode schema)
Build an instance validator tied to a schema
|
JsonSchema |
getJsonSchema(com.fasterxml.jackson.databind.JsonNode schema,
String ptr)
Build an instance validator tied to a subschema from a main schema
|
JsonSchema |
getJsonSchema(String uri)
Build an instance validator out of a schema loaded from a URI
|
com.github.fge.jsonschema.processing.Processor<FullData,FullData> |
getProcessor()
Return the raw validation processor
|
SyntaxValidator |
getSyntaxValidator()
Return the syntax validator provided by this factory
|
JsonValidator |
getValidator()
Return the main schema/instance validator provided by this factory
|
static JsonSchemaFactoryBuilder |
newBuilder()
Return a factory builder
|
JsonSchemaFactoryBuilder |
thaw()
Return a thawed instance of that factory
|
public static JsonSchemaFactory byDefault()
This default factory has validators for both draft v4 and draft v3. It defaults to draft v4.
JsonSchemaFactoryBuilder.JsonSchemaFactoryBuilder()
public static JsonSchemaFactoryBuilder newBuilder()
JsonSchemaFactoryBuilder
public JsonValidator getValidator()
JsonValidator
public SyntaxValidator getSyntaxValidator()
SyntaxValidator
public JsonSchema getJsonSchema(com.fasterxml.jackson.databind.JsonNode schema) throws com.github.fge.jsonschema.exceptions.ProcessingException
Note that the validity of the schema is not checked. Use getSyntaxValidator()
if you are not sure.
schema
- the schemaJsonSchema
com.github.fge.jsonschema.exceptions.ProcessingException
- schema is a MissingNode
com.github.fge.jsonschema.exceptions.unchecked.LoadingConfigurationError
- schema is nullpublic JsonSchema getJsonSchema(com.fasterxml.jackson.databind.JsonNode schema, String ptr) throws com.github.fge.jsonschema.exceptions.ProcessingException
Note that the validity of the schema is not checked. Use getSyntaxValidator()
if you are not sure.
schema
- the schemaptr
- a JSON Pointer as a stringJsonSchema
com.github.fge.jsonschema.exceptions.ProcessingException
- ptr
is not a valid JSON Pointer, or
resolving the pointer against the schema leads to a MissingNode
com.github.fge.jsonschema.exceptions.unchecked.LoadingConfigurationError
- schema is nullcom.github.fge.jsonschema.exceptions.unchecked.JsonReferenceError
- pointer is nullpublic JsonSchema getJsonSchema(String uri) throws com.github.fge.jsonschema.exceptions.ProcessingException
uri
- the URIJsonSchema
com.github.fge.jsonschema.exceptions.ProcessingException
- failed to load from this URIcom.github.fge.jsonschema.exceptions.unchecked.JsonReferenceError
- URI is nullpublic com.github.fge.jsonschema.processing.Processor<FullData,FullData> getProcessor()
This will allow you to chain the full validation processor with other processors of your choice. Useful if, for instance, you wish to add post checking which JSON Schema cannot do by itself.
public JsonSchemaFactoryBuilder thaw()
thaw
in interface com.github.fge.jsonschema.util.Frozen<JsonSchemaFactoryBuilder>
JsonSchemaFactoryBuilder
JsonSchemaFactoryBuilder.JsonSchemaFactoryBuilder(JsonSchemaFactory)
Copyright © 2014. All Rights Reserved.