Package dev.harrel.jsonschema
Class Validator
java.lang.Object
dev.harrel.jsonschema.Validator
Main class for performing JSON schema validation. It can be created via
ValidatorFactory
.
Configuration of Validator
is immutable. It uses schema registry to keep track of all the registered schemas,
which are registered either by registerSchema(String)
method (and its overloads) or by SchemaResolver
resolution.- See Also:
-
Nested Class Summary
Nested ClassesModifier and TypeClassDescriptionstatic final class
Result
class represents validation outcome. -
Method Summary
Modifier and TypeMethodDescriptionregisterSchema
(JsonNode schemaNode) Registers schema and generates URI for it.registerSchema
(Object schemaProviderNode) Registers schema and generates URI for it.registerSchema
(String rawSchema) Registers schema and generates URI for it.registerSchema
(URI uri, JsonNode schemaNode) Registers schema at specified URI.registerSchema
(URI uri, Object schemaProviderNode) Registers schema at specified URI.registerSchema
(URI uri, String rawSchema) Registers schema at specified URI.Validates instance JSON against a root schema resolved from provided URI.Validates instance JSON against schema resolved from provided URI.Validates instance JSON against schema resolved from provided URI.
-
Method Details
-
registerSchema
Registers schema and generates URI for it.- Parameters:
rawSchema
- string representation of schema JSON- Returns:
- automatically generated URI for the registered schema OR value of $id keyword in root schema if present
-
registerSchema
Registers schema and generates URI for it.- Parameters:
schemaProviderNode
- object representing schema JSON for currently setJsonNodeFactory
. E.g.com.fasterxml.jackson.databind.JsonNode
for defaultJsonNodeFactory
(JacksonNode.Factory
)- Returns:
- automatically generated URI for the registered schema OR value of $id keyword in root schema if present
-
registerSchema
Registers schema and generates URI for it.- Parameters:
schemaNode
-JsonNode
schema JSON, which could be created viaJsonNodeFactory
- Returns:
- automatically generated URI for the registered schema OR value of $id keyword in root schema if present
-
registerSchema
Registers schema at specified URI.- Parameters:
uri
- schema URIrawSchema
- string representation of schema JSON- Returns:
- URI provided by user OR value of $id keyword in root schema if present
-
registerSchema
Registers schema at specified URI.- Parameters:
uri
- schema URIschemaProviderNode
- object representing schema JSON for currently setJsonNodeFactory
. E.g.com.fasterxml.jackson.databind.JsonNode
for defaultJsonNodeFactory
(JacksonNode.Factory
)- Returns:
- URI provided by user OR value of $id keyword in root schema if present
-
registerSchema
Registers schema at specified URI.- Parameters:
uri
- schema URIschemaNode
-JsonNode
schema JSON, which could be created viaJsonNodeFactory
- Returns:
- URI provided by user OR value of $id keyword in root schema if present
-
validate
Validates instance JSON against schema resolved from provided URI.- Parameters:
schemaUri
- URI of schema to use for validationrawInstance
- string representation of instance JSON- Returns:
- validation result
-
validate
Validates instance JSON against schema resolved from provided URI.- Parameters:
schemaUri
- URI of schema to use for validationinstanceProviderNode
- object representing instance JSON for currently setJsonNodeFactory
. E.g.com.fasterxml.jackson.databind.JsonNode
for defaultJsonNodeFactory
(JacksonNode.Factory
)- Returns:
- validation result
-
validate
Validates instance JSON against a root schema resolved from provided URI.- Parameters:
schemaUri
- URI of a root schema to use for validationinstanceNode
-JsonNode
instance JSON, which could be created viaJsonNodeFactory
- Returns:
- validation result
-