Package com.clumd.projects.javajson.api
Class JsonSchemaEnforcer
java.lang.Object
com.clumd.projects.javajson.api.JsonSchemaEnforcer
- All Implemented Interfaces:
JsonSchemaEnforceable
Default implementation of
JsonSchemaEnforceable, to verify whether a given JSON object satisfies a given JSON
schema.-
Constructor Summary
Constructors -
Method Summary
Modifier and TypeMethodDescriptionstatic booleanA static equivalent ofvalidateWithReasoning(Json, Json).static booleanvalidateStrict(Json objectToValidate, Json againstSchema) A static equivalent ofJsonSchemaEnforceable.validateWithOutReasoning(Json, Json).booleanvalidateWithReasoning(Json objectToValidate, Json againstSchema) Validate with the potential to throw exceptions to the caller.Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, waitMethods inherited from interface com.clumd.projects.javajson.api.JsonSchemaEnforceable
validateWithOutReasoning
-
Constructor Details
-
JsonSchemaEnforcer
public JsonSchemaEnforcer()
-
-
Method Details
-
validateStrict
A static equivalent ofJsonSchemaEnforceable.validateWithOutReasoning(Json, Json).- Parameters:
objectToValidate- The JSON object to be evaluated.againstSchema- The JSON Schema to verify the object against.- Returns:
- True if the JSON object satisfies the Schema, False if there is any exception.
-
validate
A static equivalent ofvalidateWithReasoning(Json, Json).- Parameters:
objectToValidate- The JSON object to be evaluated.againstSchema- The JSON Schema to verify the object against.- Returns:
- True if the JSON object satisfies the Schema. If False, an exception will be thrown with the reason why.
-
validateWithReasoning
public boolean validateWithReasoning(Json objectToValidate, Json againstSchema) throws SchemaException Description copied from interface:JsonSchemaEnforceableValidate with the potential to throw exceptions to the caller.- Specified by:
validateWithReasoningin interfaceJsonSchemaEnforceable- Parameters:
objectToValidate- The JSON Object to be validated.againstSchema- The Schema JSON Object which defines the object to be validated.- Returns:
- True if the object passes validation, False if it fails for any reason.
- Throws:
SchemaException- Thrown to give reason/context as to why an object failed validation.
-