@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(JsonNode schema)
Build an instance validator tied to a schema
|
JsonSchema |
getJsonSchema(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
|
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(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
LoadingConfigurationError
- schema is nullpublic JsonSchema getJsonSchema(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
LoadingConfigurationError
- the schema or 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 URILoadingConfigurationError
- URI is nullpublic JsonSchemaFactoryBuilder thaw()
thaw
in interface com.github.fge.jsonschema.util.Frozen<JsonSchemaFactoryBuilder>
JsonSchemaFactoryBuilder
JsonSchemaFactoryBuilder.JsonSchemaFactoryBuilder(JsonSchemaFactory)
Copyright © 2013. All Rights Reserved.