public class Validator
extends java.lang.Object
| Modifier and Type | Class and Description |
|---|---|
static class |
Validator.ValidationErrors |
| Constructor and Description |
|---|
Validator() |
| Modifier and Type | Method and Description |
|---|---|
static com.networknt.schema.JsonSchema |
getJsonSchema(java.lang.String schema)
Retrieve
JsonSchema from string (either the schema itself, either from the classpath).No validation of the schema will be performed (equivalent to |
static com.networknt.schema.JsonSchema |
getJsonSchema(java.lang.String schema,
boolean validateSchema)
Retrieve
JsonSchema from string (either the schema itself, either from the classpath).Optional: validate the schema against the version specifications. Store it in memory to avoid reloading it. |
static void |
validate(com.fasterxml.jackson.databind.JsonNode jsonNode,
com.networknt.schema.JsonSchema jsonSchema)
Validate a json object (in JsonNode format) against a json schema.
Perform the actual validation. |
static void |
validate(com.fasterxml.jackson.databind.JsonNode jsonNode,
java.lang.String jsonSchema)
Validate a json object (in JsonNode format) against a json schema.
Perform the actual validation. |
static void |
validate(java.util.Map<java.lang.String,java.lang.Object> map,
com.networknt.schema.JsonSchema jsonSchema)
Validate a json object (in map format) against a json schema
|
static void |
validate(java.util.Map<java.lang.String,java.lang.Object> map,
java.lang.String jsonSchema)
Validate a json object (in map format) against a json schema
|
static void |
validate(java.lang.Object obj,
com.networknt.schema.JsonSchema jsonSchema)
Validate a json object against a json schema
|
static void |
validate(java.lang.Object obj,
com.networknt.schema.JsonSchema jsonSchema,
java.lang.String envelope)
Validate part of a json object against a json schema
|
static void |
validate(java.lang.Object obj,
java.lang.String jsonSchema)
Validate a json object against a json schema
|
static void |
validate(java.lang.Object obj,
java.lang.String jsonSchema,
java.lang.String envelope)
Validate part of a json object against a json schema
|
static void |
validate(java.lang.String json,
com.networknt.schema.JsonSchema jsonSchema)
Validate a json object (in string format) against a json schema
|
static void |
validate(java.lang.String json,
java.lang.String jsonSchema)
Validate a json object (in string format) against a json schema
|
public static void validate(java.lang.Object obj,
java.lang.String jsonSchema,
java.lang.String envelope)
throws ValidationException
obj - The object to validatejsonSchema - The schema used to validate: either the schema itself or a path to file in the classpath: "classpath:/path/to/schema.json"envelope - a path to a sub object within objValidationExceptionpublic static void validate(java.lang.Object obj,
com.networknt.schema.JsonSchema jsonSchema,
java.lang.String envelope)
throws ValidationException
obj - The object to validatejsonSchema - The schema used to validateenvelope - a path to a sub object within objValidationExceptionpublic static void validate(java.lang.Object obj,
java.lang.String jsonSchema)
throws ValidationException
obj - Object to validatejsonSchema - The schema used to validate: either the schema itself or a path to file in the classpath: "classpath:/path/to/schema.json"ValidationException - if validation failspublic static void validate(java.lang.Object obj,
com.networknt.schema.JsonSchema jsonSchema)
throws ValidationException
obj - Object to validatejsonSchema - The schema used to validateValidationException - if validation failspublic static void validate(java.lang.String json,
java.lang.String jsonSchema)
throws ValidationException
json - Json in string formatjsonSchema - The schema used to validate: either the schema itself or a path to file in the classpath: "classpath:/path/to/schema.json"ValidationException - if validation failspublic static void validate(java.lang.String json,
com.networknt.schema.JsonSchema jsonSchema)
throws ValidationException
json - json in string formatjsonSchema - the schema used to validate json stringValidationException - if validation failspublic static void validate(java.util.Map<java.lang.String,java.lang.Object> map,
java.lang.String jsonSchema)
throws ValidationException
map - Map to be transformed in json and validated against the schemajsonSchema - The schema used to validate: either the schema itself or a path to file in the classpath: "classpath:/path/to/schema.json"ValidationException - if validation failspublic static void validate(java.util.Map<java.lang.String,java.lang.Object> map,
com.networknt.schema.JsonSchema jsonSchema)
throws ValidationException
map - Map to be transformed in json and validated against the schemajsonSchema - the schema used to validate json mapValidationException - if validation failspublic static void validate(com.fasterxml.jackson.databind.JsonNode jsonNode,
java.lang.String jsonSchema)
throws ValidationException
jsonNode - Json to be validated against the schemajsonSchema - The schema used to validate: either the schema itself or a path to file in the classpath: "classpath:/path/to/schema.json"ValidationException - if validation failspublic static void validate(com.fasterxml.jackson.databind.JsonNode jsonNode,
com.networknt.schema.JsonSchema jsonSchema)
throws ValidationException
jsonNode - json to be validated against the schemajsonSchema - the schema to validate json nodeValidationException - if validation failspublic static com.networknt.schema.JsonSchema getJsonSchema(java.lang.String schema)
JsonSchema from string (either the schema itself, either from the classpath).getJsonSchema(schema, false)
schema - either the schema itself of a "classpath:/path/to/schema.json"public static com.networknt.schema.JsonSchema getJsonSchema(java.lang.String schema,
boolean validateSchema)
JsonSchema from string (either the schema itself, either from the classpath).schema - either the schema itself of a "classpath:/path/to/schema.json"validateSchema - specify if the schema itself must be validated against specificationsCopyright © 2020. All rights reserved.