Class Schema
- java.lang.Object
-
- com.networknt.schema.Schema
-
public class Schema extends Object implements Validator
Used for creating a schema with validators for validating inputs. This is created using SchemaRegistry#withDefaultDialect(Version, Consumer) and should be cached for performance.This is the core of json constraint implementation. It parses json constraint file and generates KeywordValidators. The class is thread safe, once it is constructed, it can be used to validate multiple json data concurrently.
Schema instances are thread-safe provided its configuration is not modified.
-
-
Nested Class Summary
Nested Classes Modifier and Type Class Description static classSchema.JsonNodePathJsonPathstatic classSchema.JsonNodePathJsonPointerstatic classSchema.JsonNodePathLegacy
-
Field Summary
Fields Modifier and Type Field Description protected SchemaparentSchemaprotected SchemaContextschemaContextprotected SchemaLocationschemaLocationprotected com.fasterxml.jackson.databind.JsonNodeschemaNodeprotected booleansuppressSubSchemaRetrieval
-
Constructor Summary
Constructors Modifier Constructor Description protectedSchema(List<KeywordValidator> validators, boolean validatorsLoaded, boolean recursiveAnchor, TypeValidator typeValidator, String id, boolean suppressSubSchemaRetrieval, com.fasterxml.jackson.databind.JsonNode schemaNode, SchemaContext schemaContext, Schema parentSchema, SchemaLocation schemaLocation, Map<String,String> errorMessage)Constructor to create a copy using fields.
-
Method Summary
All Methods Instance Methods Concrete Methods Modifier and Type Method Description protected NodePathatRoot()Get the root path.ExecutionContextcreateExecutionContext()Creates an execution context.protected SchemafetchSubSchemaNode(SchemaContext schemaContext)SchemafindAncestor()SchemafindLexicalRoot()SchemafindSchemaResourceRoot()Finds the root of the schema resource.StringgetId()protected com.fasterxml.jackson.databind.JsonNodegetNode(com.fasterxml.jackson.databind.JsonNode node, Object propertyOrIndex)protected com.fasterxml.jackson.databind.JsonNodegetNode(Object propertyOrIndex)SchemagetParentSchema()SchemagetRefSchema(NodePath fragment)com.fasterxml.jackson.databind.JsonNodegetRefSchemaNode(String ref)Find the schema node for $ref attribute.SchemaContextgetSchemaContext()SchemaLocationgetSchemaLocation()The schema location is the canonical URI of the schema object plus a JSON Pointer fragment indicating the subschema that produced a result.com.fasterxml.jackson.databind.JsonNodegetSchemaNode()SchemagetSubSchema(NodePath fragment)Gets the sub schema given the json pointer fragment.List<KeywordValidator>getValidators()booleanhasKeyword(String keyword)voidinitializeValidators()Initializes the validators'Schemainstances.booleanisRecursiveAnchor()booleanisSchemaResourceRoot()Determines if this schema resource is a schema resource root.booleanisSuppressSubSchemaRetrieval()StringtoString()END OF WALK METHODSList<Error>validate(com.fasterxml.jackson.databind.JsonNode rootNode)Validate the given root JsonNode, starting at the root of the data path.List<Error>validate(com.fasterxml.jackson.databind.JsonNode rootNode, ExecutionContextCustomizer executionCustomizer)Validate the given root JsonNode, starting at the root of the data path.<T> Tvalidate(com.fasterxml.jackson.databind.JsonNode rootNode, OutputFormat<T> format)Validates the given root JsonNode, starting at the root of the data path.<T> Tvalidate(com.fasterxml.jackson.databind.JsonNode rootNode, OutputFormat<T> format, ExecutionContextCustomizer executionCustomizer)Validates the given root JsonNode, starting at the root of the data path.<T> Tvalidate(com.fasterxml.jackson.databind.JsonNode rootNode, OutputFormat<T> format, Consumer<ExecutionContext> executionCustomizer)Validates the given root JsonNode, starting at the root of the data path.List<Error>validate(com.fasterxml.jackson.databind.JsonNode rootNode, Consumer<ExecutionContext> executionCustomizer)Validate the given root JsonNode, starting at the root of the data path.List<Error>validate(AbsoluteIri input, InputFormat inputFormat)Validate the given input string using the input format, starting at the root of the data path.List<Error>validate(AbsoluteIri input, InputFormat inputFormat, ExecutionContextCustomizer executionCustomizer)Validate the given input string using the input format, starting at the root of the data path.<T> Tvalidate(AbsoluteIri input, InputFormat inputFormat, OutputFormat<T> format)Validates the given input string using the input format, starting at the root of the data path.<T> Tvalidate(AbsoluteIri input, InputFormat inputFormat, OutputFormat<T> format, ExecutionContextCustomizer executionCustomizer)Validates the given input string using the input format, starting at the root of the data path.<T> Tvalidate(AbsoluteIri input, InputFormat inputFormat, OutputFormat<T> format, Consumer<ExecutionContext> executionCustomizer)Validates the given input string using the input format, starting at the root of the data path.List<Error>validate(AbsoluteIri input, InputFormat inputFormat, Consumer<ExecutionContext> executionCustomizer)Validate the given input string using the input format, starting at the root of the data path.voidvalidate(ExecutionContext executionContext, com.fasterxml.jackson.databind.JsonNode node)voidvalidate(ExecutionContext executionContext, com.fasterxml.jackson.databind.JsonNode jsonNode, com.fasterxml.jackson.databind.JsonNode rootNode, NodePath instanceLocation)START OF VALIDATE METHODS<T> Tvalidate(ExecutionContext executionContext, com.fasterxml.jackson.databind.JsonNode node, OutputFormat<T> format)Validates to a format.<T> Tvalidate(ExecutionContext executionContext, com.fasterxml.jackson.databind.JsonNode node, OutputFormat<T> format, ExecutionContextCustomizer executionCustomizer)Validates to a format.<T> Tvalidate(ExecutionContext executionContext, com.fasterxml.jackson.databind.JsonNode node, OutputFormat<T> format, Consumer<ExecutionContext> executionCustomizer)Validates the given input string using the input format, starting at the root of the data path.List<Error>validate(ExecutionContext executionContext, String input, InputFormat inputFormat)Validate the given input string using the input format, starting at the root of the data path.List<Error>validate(ExecutionContext executionContext, String input, InputFormat inputFormat, ExecutionContextCustomizer executionCustomizer)Validate the given input string using the input format, starting at the root of the data path.<T> Tvalidate(ExecutionContext executionContext, String input, InputFormat inputFormat, OutputFormat<T> format)Validates the given input string using the input format, starting at the root of the data path.<T> Tvalidate(ExecutionContext executionContext, String input, InputFormat inputFormat, OutputFormat<T> format, ExecutionContextCustomizer executionCustomizer)Validates the given input string using the input format, starting at the root of the data path.<T> Tvalidate(ExecutionContext executionContext, String input, InputFormat inputFormat, OutputFormat<T> format, Consumer<ExecutionContext> executionCustomizer)Validates the given input string using the input format, starting at the root of the data path.List<Error>validate(ExecutionContext executionContext, String input, InputFormat inputFormat, Consumer<ExecutionContext> executionCustomizer)Validate the given input string using the input format, starting at the root of the data path.List<Error>validate(String input, InputFormat inputFormat)Validate the given input string using the input format, starting at the root of the data path.List<Error>validate(String input, InputFormat inputFormat, ExecutionContextCustomizer executionCustomizer)Validate the given input string using the input format, starting at the root of the data path.<T> Tvalidate(String input, InputFormat inputFormat, OutputFormat<T> format)Validates the given input string using the input format, starting at the root of the data path.<T> Tvalidate(String input, InputFormat inputFormat, OutputFormat<T> format, ExecutionContextCustomizer executionCustomizer)Validates the given input string using the input format, starting at the root of the data path.<T> Tvalidate(String input, InputFormat inputFormat, OutputFormat<T> format, Consumer<ExecutionContext> executionCustomizer)Validates the given input string using the input format, starting at the root of the data path.List<Error>validate(String input, InputFormat inputFormat, Consumer<ExecutionContext> executionCustomizer)Validate the given input string using the input format, starting at the root of the data path.Resultwalk(com.fasterxml.jackson.databind.JsonNode node, boolean validate)Walk the JSON node.Resultwalk(com.fasterxml.jackson.databind.JsonNode node, boolean validate, ExecutionContextCustomizer executionCustomizer)Walk the JSON node.Resultwalk(com.fasterxml.jackson.databind.JsonNode node, boolean validate, Consumer<ExecutionContext> executionCustomizer)Walk the JSON node.<T> Twalk(com.fasterxml.jackson.databind.JsonNode node, OutputFormat<T> outputFormat, boolean validate)Walk the JSON node.Resultwalk(AbsoluteIri input, InputFormat inputFormat, boolean validate)Walk the input.Resultwalk(AbsoluteIri input, InputFormat inputFormat, boolean validate, ExecutionContextCustomizer executionCustomizer)Walk the input.Resultwalk(AbsoluteIri input, InputFormat inputFormat, boolean validate, Consumer<ExecutionContext> executionCustomizer)Walk the input.Resultwalk(ExecutionContext executionContext, com.fasterxml.jackson.databind.JsonNode node, boolean validate)Walk the JSON node.Resultwalk(ExecutionContext executionContext, com.fasterxml.jackson.databind.JsonNode node, boolean validate, ExecutionContextCustomizer executionCustomizer)Walk the JSON node.Resultwalk(ExecutionContext executionContext, com.fasterxml.jackson.databind.JsonNode node, boolean validate, Consumer<ExecutionContext> executionCustomizer)Walk the JSON node.voidwalk(ExecutionContext executionContext, com.fasterxml.jackson.databind.JsonNode node, com.fasterxml.jackson.databind.JsonNode rootNode, NodePath instanceLocation, boolean shouldValidateSchema)This is default implementation of walk method.<T> Twalk(ExecutionContext executionContext, com.fasterxml.jackson.databind.JsonNode node, OutputFormat<T> outputFormat, boolean validate, ExecutionContextCustomizer executionCustomizer)Walk the JSON node.<T> Twalk(ExecutionContext executionContext, com.fasterxml.jackson.databind.JsonNode node, OutputFormat<T> outputFormat, boolean validate, Consumer<ExecutionContext> executionCustomizer)Walk the JSON node.Resultwalk(ExecutionContext executionContext, String input, InputFormat inputFormat, boolean validate)Walk the input.Resultwalk(ExecutionContext executionContext, String input, InputFormat inputFormat, boolean validate, ExecutionContextCustomizer executionCustomizer)Walk the input.<T> Twalk(ExecutionContext executionContext, String input, InputFormat inputFormat, OutputFormat<T> outputFormat, boolean validate)Walk the input.<T> Twalk(ExecutionContext executionContext, String input, InputFormat inputFormat, OutputFormat<T> outputFormat, boolean validate, ExecutionContextCustomizer executionCustomizer)Walk the input.Resultwalk(String input, InputFormat inputFormat, boolean validate)Walk the input.Resultwalk(String input, InputFormat inputFormat, boolean validate, ExecutionContextCustomizer executionCustomizer)Walk the input.Resultwalk(String input, InputFormat inputFormat, boolean validate, Consumer<ExecutionContext> executionCustomizer)Walk the input.ResultwalkAtNode(ExecutionContext executionContext, com.fasterxml.jackson.databind.JsonNode node, com.fasterxml.jackson.databind.JsonNode rootNode, NodePath instanceLocation, boolean validate)Walk at the node.
-
-
-
Field Detail
-
schemaNode
protected final com.fasterxml.jackson.databind.JsonNode schemaNode
-
parentSchema
protected final Schema parentSchema
-
schemaLocation
protected final SchemaLocation schemaLocation
-
schemaContext
protected final SchemaContext schemaContext
-
suppressSubSchemaRetrieval
protected final boolean suppressSubSchemaRetrieval
-
-
Constructor Detail
-
Schema
protected Schema(List<KeywordValidator> validators, boolean validatorsLoaded, boolean recursiveAnchor, TypeValidator typeValidator, String id, boolean suppressSubSchemaRetrieval, com.fasterxml.jackson.databind.JsonNode schemaNode, SchemaContext schemaContext, Schema parentSchema, SchemaLocation schemaLocation, Map<String,String> errorMessage)
Constructor to create a copy using fields.- Parameters:
validators- the validatorsvalidatorsLoaded- whether the validators are preloadedrecursiveAnchor- whether this is has a recursive anchorid- the idsuppressSubSchemaRetrieval- to suppress sub schema retrievalschemaNode- the schema nodeschemaContext- the schema contextparentSchema- the parent schemaschemaLocation- the schema locationerrorMessage- the error message
-
-
Method Detail
-
getSchemaNode
public com.fasterxml.jackson.databind.JsonNode getSchemaNode()
-
getSchemaLocation
public SchemaLocation getSchemaLocation()
Description copied from interface:ValidatorThe schema location is the canonical URI of the schema object plus a JSON Pointer fragment indicating the subschema that produced a result. In contrast with the evaluation path, the schema location MUST NOT include by-reference applicators such as $ref or $dynamicRef.- Specified by:
getSchemaLocationin interfaceValidator- Returns:
- the schema location
-
getParentSchema
public Schema getParentSchema()
-
isSuppressSubSchemaRetrieval
public boolean isSuppressSubSchemaRetrieval()
-
fetchSubSchemaNode
protected Schema fetchSubSchemaNode(SchemaContext schemaContext)
-
validate
public void validate(ExecutionContext executionContext, com.fasterxml.jackson.databind.JsonNode node)
-
atRoot
protected NodePath atRoot()
Get the root path.- Returns:
- The path.
-
getSchemaContext
public SchemaContext getSchemaContext()
-
hasKeyword
public boolean hasKeyword(String keyword)
-
getRefSchemaNode
public com.fasterxml.jackson.databind.JsonNode getRefSchemaNode(String ref)
Find the schema node for $ref attribute.- Parameters:
ref- String- Returns:
- JsonNode
-
getSubSchema
public Schema getSubSchema(NodePath fragment)
Gets the sub schema given the json pointer fragment.- Parameters:
fragment- the json pointer fragment- Returns:
- the schema
-
getNode
protected com.fasterxml.jackson.databind.JsonNode getNode(Object propertyOrIndex)
-
getNode
protected com.fasterxml.jackson.databind.JsonNode getNode(com.fasterxml.jackson.databind.JsonNode node, Object propertyOrIndex)
-
findLexicalRoot
public Schema findLexicalRoot()
-
findSchemaResourceRoot
public Schema findSchemaResourceRoot()
Finds the root of the schema resource.This is either the schema document root or the subschema resource root.
- Returns:
- the root of the schema
-
isSchemaResourceRoot
public boolean isSchemaResourceRoot()
Determines if this schema resource is a schema resource root.This is either the schema document root or the subschema resource root.
- Returns:
- if this schema is a schema resource root
-
getId
public String getId()
-
findAncestor
public Schema findAncestor()
-
validate
public void validate(ExecutionContext executionContext, com.fasterxml.jackson.databind.JsonNode jsonNode, com.fasterxml.jackson.databind.JsonNode rootNode, NodePath instanceLocation)
START OF VALIDATE METHODS
-
validate
public List<Error> validate(com.fasterxml.jackson.databind.JsonNode rootNode)
Validate the given root JsonNode, starting at the root of the data path.Note that since Draft 2019-09 by default format generates only annotations and not assertions.
Use
ExecutionConfig.BuilderSupport.formatAssertionsEnabled(Boolean)to override the default.- Parameters:
rootNode- the root node- Returns:
- A list of Error if there is any validation error, or an empty list if there is no error.
-
validate
public List<Error> validate(com.fasterxml.jackson.databind.JsonNode rootNode, ExecutionContextCustomizer executionCustomizer)
Validate the given root JsonNode, starting at the root of the data path.Note that since Draft 2019-09 by default format generates only annotations and not assertions.
Use
ExecutionConfig.BuilderSupport.formatAssertionsEnabled(Boolean)to override the default.- Parameters:
rootNode- the root nodeexecutionCustomizer- the execution customizer- Returns:
- the assertions
-
validate
public List<Error> validate(com.fasterxml.jackson.databind.JsonNode rootNode, Consumer<ExecutionContext> executionCustomizer)
Validate the given root JsonNode, starting at the root of the data path.Note that since Draft 2019-09 by default format generates only annotations and not assertions.
Use
ExecutionConfig.BuilderSupport.formatAssertionsEnabled(Boolean)to override the default.- Parameters:
rootNode- the root nodeexecutionCustomizer- the execution customizer- Returns:
- the assertions
-
validate
public <T> T validate(com.fasterxml.jackson.databind.JsonNode rootNode, OutputFormat<T> format)Validates the given root JsonNode, starting at the root of the data path. The output will be formatted using the formatter specified.Note that since Draft 2019-09 by default format generates only annotations and not assertions.
Use
ExecutionConfig.BuilderSupport.formatAssertionsEnabled(Boolean)to override the default.- Type Parameters:
T- the result type- Parameters:
rootNode- the root nodeformat- the formatter- Returns:
- the result
-
validate
public <T> T validate(com.fasterxml.jackson.databind.JsonNode rootNode, OutputFormat<T> format, ExecutionContextCustomizer executionCustomizer)Validates the given root JsonNode, starting at the root of the data path. The output will be formatted using the formatter specified.Note that since Draft 2019-09 by default format generates only annotations and not assertions.
Use
ExecutionConfig.BuilderSupport.formatAssertionsEnabled(Boolean)to override the default.- Type Parameters:
T- the result type- Parameters:
rootNode- the root nodeformat- the formatterexecutionCustomizer- the execution customizer- Returns:
- the result
-
validate
public <T> T validate(com.fasterxml.jackson.databind.JsonNode rootNode, OutputFormat<T> format, Consumer<ExecutionContext> executionCustomizer)Validates the given root JsonNode, starting at the root of the data path. The output will be formatted using the formatter specified.Note that since Draft 2019-09 by default format generates only annotations and not assertions.
Use
ExecutionConfig.BuilderSupport.formatAssertionsEnabled(Boolean)to override the default.- Type Parameters:
T- the result type- Parameters:
rootNode- the root nodeformat- the formatterexecutionCustomizer- the execution customizer- Returns:
- the result
-
validate
public List<Error> validate(String input, InputFormat inputFormat)
Validate the given input string using the input format, starting at the root of the data path.Note that since Draft 2019-09 by default format generates only annotations and not assertions.
Use
ExecutionConfig.BuilderSupport.formatAssertionsEnabled(Boolean)to override the default.- Parameters:
input- the inputinputFormat- the inputFormat- Returns:
- A list of Error if there is any validation error, or an empty list if there is no error.
-
validate
public List<Error> validate(String input, InputFormat inputFormat, ExecutionContextCustomizer executionCustomizer)
Validate the given input string using the input format, starting at the root of the data path.Note that since Draft 2019-09 by default format generates only annotations and not assertions.
Use
ExecutionConfig.BuilderSupport.formatAssertionsEnabled(Boolean)to override the default.- Parameters:
input- the inputinputFormat- the inputFormatexecutionCustomizer- the execution customizer- Returns:
- the assertions
-
validate
public List<Error> validate(String input, InputFormat inputFormat, Consumer<ExecutionContext> executionCustomizer)
Validate the given input string using the input format, starting at the root of the data path.Note that since Draft 2019-09 by default format generates only annotations and not assertions.
Use
ExecutionConfig.BuilderSupport.formatAssertionsEnabled(Boolean)to override the default.- Parameters:
input- the inputinputFormat- the inputFormatexecutionCustomizer- the execution customizer- Returns:
- the assertions
-
validate
public <T> T validate(String input, InputFormat inputFormat, OutputFormat<T> format)
Validates the given input string using the input format, starting at the root of the data path. The output will be formatted using the formatter specified.Note that since Draft 2019-09 by default format generates only annotations and not assertions.
Use
ExecutionConfig.BuilderSupport.formatAssertionsEnabled(Boolean)to override the default.- Type Parameters:
T- the result type- Parameters:
input- the inputinputFormat- the inputFormatformat- the formatter- Returns:
- the result
-
validate
public <T> T validate(String input, InputFormat inputFormat, OutputFormat<T> format, ExecutionContextCustomizer executionCustomizer)
Validates the given input string using the input format, starting at the root of the data path. The output will be formatted using the formatter specified.Note that since Draft 2019-09 by default format generates only annotations and not assertions.
Use
ExecutionConfig.BuilderSupport.formatAssertionsEnabled(Boolean)to override the default.- Type Parameters:
T- the result type- Parameters:
input- the inputinputFormat- the inputFormatformat- the formatterexecutionCustomizer- the execution customizer- Returns:
- the result
-
validate
public <T> T validate(String input, InputFormat inputFormat, OutputFormat<T> format, Consumer<ExecutionContext> executionCustomizer)
Validates the given input string using the input format, starting at the root of the data path. The output will be formatted using the formatter specified.Note that since Draft 2019-09 by default format generates only annotations and not assertions.
Use
ExecutionConfig.BuilderSupport.formatAssertionsEnabled(Boolean)to override the default.- Type Parameters:
T- the result type- Parameters:
input- the inputinputFormat- the inputFormatformat- the formatterexecutionCustomizer- the execution customizer- Returns:
- the result
-
validate
public List<Error> validate(AbsoluteIri input, InputFormat inputFormat)
Validate the given input string using the input format, starting at the root of the data path.Note that since Draft 2019-09 by default format generates only annotations and not assertions.
Use
ExecutionConfig.BuilderSupport.formatAssertionsEnabled(Boolean)to override the default.- Parameters:
input- the inputinputFormat- the inputFormat- Returns:
- A list of Error if there is any validation error, or an empty list if there is no error.
-
validate
public List<Error> validate(AbsoluteIri input, InputFormat inputFormat, ExecutionContextCustomizer executionCustomizer)
Validate the given input string using the input format, starting at the root of the data path.Note that since Draft 2019-09 by default format generates only annotations and not assertions.
Use
ExecutionConfig.BuilderSupport.formatAssertionsEnabled(Boolean)to override the default.- Parameters:
input- the inputinputFormat- the inputFormatexecutionCustomizer- the execution customizer- Returns:
- the assertions
-
validate
public List<Error> validate(AbsoluteIri input, InputFormat inputFormat, Consumer<ExecutionContext> executionCustomizer)
Validate the given input string using the input format, starting at the root of the data path.Note that since Draft 2019-09 by default format generates only annotations and not assertions.
Use
ExecutionConfig.BuilderSupport.formatAssertionsEnabled(Boolean)to override the default.- Parameters:
input- the inputinputFormat- the inputFormatexecutionCustomizer- the execution customizer- Returns:
- the assertions
-
validate
public <T> T validate(AbsoluteIri input, InputFormat inputFormat, OutputFormat<T> format)
Validates the given input string using the input format, starting at the root of the data path. The output will be formatted using the formatter specified.Note that since Draft 2019-09 by default format generates only annotations and not assertions.
Use
ExecutionConfig.BuilderSupport.formatAssertionsEnabled(Boolean)to override the default.- Type Parameters:
T- the result type- Parameters:
input- the inputinputFormat- the inputFormatformat- the formatter- Returns:
- the result
-
validate
public <T> T validate(AbsoluteIri input, InputFormat inputFormat, OutputFormat<T> format, ExecutionContextCustomizer executionCustomizer)
Validates the given input string using the input format, starting at the root of the data path. The output will be formatted using the formatter specified.Note that since Draft 2019-09 by default format generates only annotations and not assertions.
Use
ExecutionConfig.BuilderSupport.formatAssertionsEnabled(Boolean)to override the default.- Type Parameters:
T- the result type- Parameters:
input- the inputinputFormat- the inputFormatformat- the formatterexecutionCustomizer- the execution customizer- Returns:
- the result
-
validate
public <T> T validate(AbsoluteIri input, InputFormat inputFormat, OutputFormat<T> format, Consumer<ExecutionContext> executionCustomizer)
Validates the given input string using the input format, starting at the root of the data path. The output will be formatted using the formatter specified.Note that since Draft 2019-09 by default format generates only annotations and not assertions.
Use
ExecutionConfig.BuilderSupport.formatAssertionsEnabled(Boolean)to override the default.- Type Parameters:
T- the result type- Parameters:
input- the inputinputFormat- the inputFormatformat- the formatterexecutionCustomizer- the execution customizer- Returns:
- the result
-
validate
public List<Error> validate(ExecutionContext executionContext, String input, InputFormat inputFormat)
Validate the given input string using the input format, starting at the root of the data path.Note that since Draft 2019-09 by default format generates only annotations and not assertions.
Use
ExecutionConfig.BuilderSupport.formatAssertionsEnabled(Boolean)to override the default.- Parameters:
executionContext- the execution contextinput- the inputinputFormat- the inputFormat- Returns:
- A list of Error if there is any validation error, or an empty list if there is no error.
-
validate
public List<Error> validate(ExecutionContext executionContext, String input, InputFormat inputFormat, ExecutionContextCustomizer executionCustomizer)
Validate the given input string using the input format, starting at the root of the data path.Note that since Draft 2019-09 by default format generates only annotations and not assertions.
Use
ExecutionConfig.BuilderSupport.formatAssertionsEnabled(Boolean)to override the default.- Parameters:
executionContext- the execution contextinput- the inputinputFormat- the inputFormatexecutionCustomizer- the execution customizer- Returns:
- the assertions
-
validate
public List<Error> validate(ExecutionContext executionContext, String input, InputFormat inputFormat, Consumer<ExecutionContext> executionCustomizer)
Validate the given input string using the input format, starting at the root of the data path.Note that since Draft 2019-09 by default format generates only annotations and not assertions.
Use
ExecutionConfig.BuilderSupport.formatAssertionsEnabled(Boolean)to override the default.- Parameters:
executionContext- the execution contextinput- the inputinputFormat- the inputFormatexecutionCustomizer- the execution customizer- Returns:
- the assertions
-
validate
public <T> T validate(ExecutionContext executionContext, String input, InputFormat inputFormat, OutputFormat<T> format)
Validates the given input string using the input format, starting at the root of the data path. The output will be formatted using the formatter specified.Note that since Draft 2019-09 by default format generates only annotations and not assertions.
Use
ExecutionConfig.BuilderSupport.formatAssertionsEnabled(Boolean)to override the default.- Type Parameters:
T- the result type- Parameters:
executionContext- the execution contextinput- the inputinputFormat- the inputFormatformat- the formatter- Returns:
- the result
-
validate
public <T> T validate(ExecutionContext executionContext, String input, InputFormat inputFormat, OutputFormat<T> format, ExecutionContextCustomizer executionCustomizer)
Validates the given input string using the input format, starting at the root of the data path. The output will be formatted using the formatter specified.Note that since Draft 2019-09 by default format generates only annotations and not assertions.
Use
ExecutionConfig.BuilderSupport.formatAssertionsEnabled(Boolean)to override the default.- Type Parameters:
T- the result type- Parameters:
executionContext- the execution contextinput- the inputinputFormat- the inputFormatformat- the formatterexecutionCustomizer- the execution customizer- Returns:
- the result
-
validate
public <T> T validate(ExecutionContext executionContext, String input, InputFormat inputFormat, OutputFormat<T> format, Consumer<ExecutionContext> executionCustomizer)
Validates the given input string using the input format, starting at the root of the data path. The output will be formatted using the formatter specified.Note that since Draft 2019-09 by default format generates only annotations and not assertions.
Use
ExecutionConfig.BuilderSupport.formatAssertionsEnabled(Boolean)to override the default.- Type Parameters:
T- the result type- Parameters:
executionContext- the execution contextinput- the inputinputFormat- the inputFormatformat- the formatterexecutionCustomizer- the execution customizer- Returns:
- the result
-
validate
public <T> T validate(ExecutionContext executionContext, com.fasterxml.jackson.databind.JsonNode node, OutputFormat<T> format)
Validates to a format.- Type Parameters:
T- the result type- Parameters:
executionContext- the execution contextnode- the nodeformat- the format- Returns:
- the result
-
validate
public <T> T validate(ExecutionContext executionContext, com.fasterxml.jackson.databind.JsonNode node, OutputFormat<T> format, Consumer<ExecutionContext> executionCustomizer)
Validates the given input string using the input format, starting at the root of the data path. The output will be formatted using the formatter specified.Note that since Draft 2019-09 by default format generates only annotations and not assertions.
Use
ExecutionConfig.BuilderSupport.formatAssertionsEnabled(Boolean)to override the default.- Type Parameters:
T- the result type- Parameters:
executionContext- the execution contextnode- the nodeformat- the formatterexecutionCustomizer- the execution customizer- Returns:
- the result
-
validate
public <T> T validate(ExecutionContext executionContext, com.fasterxml.jackson.databind.JsonNode node, OutputFormat<T> format, ExecutionContextCustomizer executionCustomizer)
Validates to a format.- Type Parameters:
T- the result type- Parameters:
executionContext- the execution contextnode- the nodeformat- the formatexecutionCustomizer- the customizer- Returns:
- the result
-
walk
public Result walk(ExecutionContext executionContext, com.fasterxml.jackson.databind.JsonNode node, boolean validate, ExecutionContextCustomizer executionCustomizer)
Walk the JSON node.- Parameters:
executionContext- the execution contextnode- the inputvalidate- true to validate the input against the schemaexecutionCustomizer- the customizer- Returns:
- the validation result
-
walk
public <T> T walk(ExecutionContext executionContext, com.fasterxml.jackson.databind.JsonNode node, OutputFormat<T> outputFormat, boolean validate, ExecutionContextCustomizer executionCustomizer)
Walk the JSON node.- Type Parameters:
T- the result type- Parameters:
executionContext- the execution contextnode- the inputoutputFormat- the output formatvalidate- true to validate the input against the schemaexecutionCustomizer- the customizer- Returns:
- the validation result
-
walk
public Result walk(ExecutionContext executionContext, com.fasterxml.jackson.databind.JsonNode node, boolean validate, Consumer<ExecutionContext> executionCustomizer)
Walk the JSON node.- Parameters:
executionContext- the execution contextnode- the inputvalidate- true to validate the input against the schemaexecutionCustomizer- the customizer- Returns:
- the validation result
-
walk
public <T> T walk(ExecutionContext executionContext, com.fasterxml.jackson.databind.JsonNode node, OutputFormat<T> outputFormat, boolean validate, Consumer<ExecutionContext> executionCustomizer)
Walk the JSON node.- Type Parameters:
T- the result type- Parameters:
executionContext- the execution contextnode- the inputoutputFormat- the output formatvalidate- true to validate the input against the schemaexecutionCustomizer- the customizer- Returns:
- the validation result
-
walk
public Result walk(ExecutionContext executionContext, com.fasterxml.jackson.databind.JsonNode node, boolean validate)
Walk the JSON node.- Parameters:
executionContext- the execution contextnode- the inputvalidate- true to validate the input against the schema- Returns:
- the validation result
-
walk
public Result walk(ExecutionContext executionContext, String input, InputFormat inputFormat, boolean validate)
Walk the input.- Parameters:
executionContext- the execution contextinput- the inputinputFormat- the input formatvalidate- true to validate the input against the schema- Returns:
- the validation result
-
walk
public <T> T walk(ExecutionContext executionContext, String input, InputFormat inputFormat, OutputFormat<T> outputFormat, boolean validate)
Walk the input.- Type Parameters:
T- the result type- Parameters:
executionContext- the execution contextinput- the inputinputFormat- the input formatoutputFormat- the output formatvalidate- true to validate the input against the schema- Returns:
- the validation result
-
walk
public Result walk(ExecutionContext executionContext, String input, InputFormat inputFormat, boolean validate, ExecutionContextCustomizer executionCustomizer)
Walk the input.- Parameters:
executionContext- the execution contextinput- the inputinputFormat- the input formatvalidate- true to validate the input against the schemaexecutionCustomizer- the customizer- Returns:
- the validation result
-
walk
public <T> T walk(ExecutionContext executionContext, String input, InputFormat inputFormat, OutputFormat<T> outputFormat, boolean validate, ExecutionContextCustomizer executionCustomizer)
Walk the input.- Type Parameters:
T- the result type- Parameters:
executionContext- the execution contextinput- the inputinputFormat- the input formatoutputFormat- the output formatvalidate- true to validate the input against the schemaexecutionCustomizer- the customizer- Returns:
- the validation result
-
walk
public Result walk(com.fasterxml.jackson.databind.JsonNode node, boolean validate)
Walk the JSON node.- Parameters:
node- the inputvalidate- true to validate the input against the schema- Returns:
- the validation result
-
walk
public Result walk(com.fasterxml.jackson.databind.JsonNode node, boolean validate, ExecutionContextCustomizer executionCustomizer)
Walk the JSON node.- Parameters:
node- the inputvalidate- true to validate the input against the schemaexecutionCustomizer- the customizer- Returns:
- the validation result
-
walk
public Result walk(com.fasterxml.jackson.databind.JsonNode node, boolean validate, Consumer<ExecutionContext> executionCustomizer)
Walk the JSON node.- Parameters:
node- the inputvalidate- true to validate the input against the schemaexecutionCustomizer- the customizer- Returns:
- the validation result
-
walk
public <T> T walk(com.fasterxml.jackson.databind.JsonNode node, OutputFormat<T> outputFormat, boolean validate)Walk the JSON node.- Type Parameters:
T- the result type- Parameters:
node- the inputvalidate- true to validate the input against the schemaoutputFormat- the output format- Returns:
- the validation result
-
walk
public Result walk(String input, InputFormat inputFormat, boolean validate)
Walk the input.- Parameters:
input- the inputinputFormat- the input formatvalidate- true to validate the input against the schema- Returns:
- the validation result
-
walk
public Result walk(String input, InputFormat inputFormat, boolean validate, ExecutionContextCustomizer executionCustomizer)
Walk the input.- Parameters:
input- the inputinputFormat- the input formatvalidate- true to validate the input against the schemaexecutionCustomizer- the customizer- Returns:
- the validation result
-
walk
public Result walk(String input, InputFormat inputFormat, boolean validate, Consumer<ExecutionContext> executionCustomizer)
Walk the input.- Parameters:
input- the inputinputFormat- the input formatvalidate- true to validate the input against the schemaexecutionCustomizer- the customizer- Returns:
- the validation result
-
walk
public Result walk(AbsoluteIri input, InputFormat inputFormat, boolean validate)
Walk the input.- Parameters:
input- the inputinputFormat- the input formatvalidate- true to validate the input against the schema- Returns:
- the validation result
-
walk
public Result walk(AbsoluteIri input, InputFormat inputFormat, boolean validate, ExecutionContextCustomizer executionCustomizer)
Walk the input.- Parameters:
input- the inputinputFormat- the input formatvalidate- true to validate the input against the schemaexecutionCustomizer- the customizer- Returns:
- the validation result
-
walk
public Result walk(AbsoluteIri input, InputFormat inputFormat, boolean validate, Consumer<ExecutionContext> executionCustomizer)
Walk the input.- Parameters:
input- the inputinputFormat- the input formatvalidate- true to validate the input against the schemaexecutionCustomizer- the customizer- Returns:
- the validation result
-
walkAtNode
public Result walkAtNode(ExecutionContext executionContext, com.fasterxml.jackson.databind.JsonNode node, com.fasterxml.jackson.databind.JsonNode rootNode, NodePath instanceLocation, boolean validate)
Walk at the node.- Parameters:
executionContext- the execution contentnode- the current noderootNode- the root nodeinstanceLocation- the instance locationvalidate- true to validate the input against the schema- Returns:
- the validation result
-
walk
public void walk(ExecutionContext executionContext, com.fasterxml.jackson.databind.JsonNode node, com.fasterxml.jackson.databind.JsonNode rootNode, NodePath instanceLocation, boolean shouldValidateSchema)
Description copied from interface:ValidatorThis is default implementation of walk method. Its job is to call the validate method if shouldValidateSchema is enabled.- Specified by:
walkin interfaceValidator- Specified by:
walkin interfaceWalker- Parameters:
executionContext- the execution contextnode- the instance node being processedrootNode- the instance document that the instance node belongs toinstanceLocation- the location of the instance node being processedshouldValidateSchema- true to validate the schema while walking
-
getValidators
public List<KeywordValidator> getValidators()
-
initializeValidators
public void initializeValidators()
Initializes the validators'Schemainstances. For avoiding issues with concurrency, in 1.0.49 theSchemainstances affiliated with validators were modified to no more preload the schema and lazy loading is used instead.This comes with the issue that this way you cannot rely on validating important schema features, in particular
$refresolution at instantiation fromSchemaRegistry.By calling
initializeValidatorsyou can enforce preloading of theSchemainstances of the validators.
-
isRecursiveAnchor
public boolean isRecursiveAnchor()
-
createExecutionContext
public ExecutionContext createExecutionContext()
Creates an execution context.- Returns:
- the execution context
-
-