@Immutable public final class JsonSchemaFactory extends Object implements 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;
JsonSchemaImpl
, 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
|
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(JsonNode schema) throws ProcessingException
Note that the validity of the schema is not checked. Use getSyntaxValidator()
if you are not sure.
schema
- the schemaJsonSchema
ProcessingException
- schema is a MissingNode
NullPointerException
- schema is nullpublic JsonSchema getJsonSchema(JsonNode schema, String ptr) throws 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
ProcessingException
- ptr
is not a valid JSON Pointer, or
resolving the pointer against the schema leads to a MissingNode
NullPointerException
- schema is null, or pointer is nullpublic JsonSchema getJsonSchema(String uri) throws ProcessingException
uri
- the URIJsonSchema
ProcessingException
- failed to load from this URINullPointerException
- URI is nullpublic 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 Frozen<JsonSchemaFactoryBuilder>
JsonSchemaFactoryBuilder
JsonSchemaFactoryBuilder.JsonSchemaFactoryBuilder(JsonSchemaFactory)