Module dev.metaschema.core
Class JsonSchemaContentValidator
java.lang.Object
dev.metaschema.core.model.AbstractResourceResolver
dev.metaschema.core.model.validation.AbstractContentValidator
dev.metaschema.core.model.validation.JsonSchemaContentValidator
- All Implemented Interfaces:
IResourceResolver,IContentValidator
Validates JSON content against a JSON schema.
-
Nested Class Summary
Nested ClassesModifier and TypeClassDescriptionstatic classRecords an identified individual validation result found during JSON schema validation. -
Constructor Summary
ConstructorsModifierConstructorDescriptionConstruct a new JSON schema validator using the provided input stream to load the JSON schema.JsonSchemaContentValidator(Reader reader) Construct a new JSON schema validator using the provided reader to load the JSON schema.protectedJsonSchemaContentValidator(org.everit.json.schema.Schema schema) Construct a new JSON schema validator using the preloaded JSON schema.JsonSchemaContentValidator(org.json.JSONObject jsonSchema) Construct a new JSON schema validator using the provided JSON object for the JSON schema.protectedJsonSchemaContentValidator(org.json.JSONTokener tokenizer) Construct a new JSON schema validator using the provided JSON tokenizer to load the schema. -
Method Summary
Modifier and TypeMethodDescriptionhandleValidationException(org.everit.json.schema.ValidationException exception, URI resourceUri) Build validation findings from a validation exception.validate(InputStream is, URI resourceUri) Validate the resource associated with the provided input streamis.Validate the provided JSON.Methods inherited from class dev.metaschema.core.model.validation.AbstractContentValidator
validateMethods inherited from class dev.metaschema.core.model.AbstractResourceResolver
getUriResolver, setUriResolverMethods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, waitMethods inherited from interface dev.metaschema.core.model.validation.IContentValidator
validate, validateMethods inherited from interface dev.metaschema.core.model.IResourceResolver
resolve
-
Constructor Details
-
JsonSchemaContentValidator
Construct a new JSON schema validator using the provided reader to load the JSON schema.- Parameters:
reader- the JSON schema reader
-
JsonSchemaContentValidator
Construct a new JSON schema validator using the provided input stream to load the JSON schema.- Parameters:
is- the JSON schema input source
-
JsonSchemaContentValidator
public JsonSchemaContentValidator(@NonNull org.json.JSONObject jsonSchema) Construct a new JSON schema validator using the provided JSON object for the JSON schema.- Parameters:
jsonSchema- the JSON schema
-
JsonSchemaContentValidator
protected JsonSchemaContentValidator(@NonNull org.json.JSONTokener tokenizer) Construct a new JSON schema validator using the provided JSON tokenizer to load the schema.- Parameters:
tokenizer- the JSON schema token stream
-
JsonSchemaContentValidator
protected JsonSchemaContentValidator(@NonNull org.everit.json.schema.Schema schema) Construct a new JSON schema validator using the preloaded JSON schema.- Parameters:
schema- the preloaded JSON schema
-
-
Method Details
-
validate
Description copied from interface:IContentValidatorValidate the resource associated with the provided input streamis.- Parameters:
is- an input stream to access the resourceresourceUri- the URI of the resource to validate- Returns:
- the result of the validation
- Throws:
IOException- if an error occurred while performing validation
-
validate
@NonNull public IValidationResult validate(@NonNull org.json.JSONObject json, @NonNull URI resourceUri) Validate the provided JSON.- Parameters:
json- the JSON to validateresourceUri- the source URI for the JSON to validate- Returns:
- the validation results
-
handleValidationException
@NonNull protected Stream<JsonSchemaContentValidator.JsonValidationFinding> handleValidationException(@NonNull org.everit.json.schema.ValidationException exception, @NonNull URI resourceUri) Build validation findings from a validation exception.- Parameters:
exception- the JSON schema validation exception generated during schema validation representing the issueresourceUri- the resource the issue was found in- Returns:
- the stream of findings
-