Class JsonSchemaEnforcer

java.lang.Object
com.clumd.projects.javajson.api.JsonSchemaEnforcer
All Implemented Interfaces:
JsonSchemaEnforceable

public final class JsonSchemaEnforcer
extends Object
implements JsonSchemaEnforceable
Default implementation of JsonSchemaEnforceable, to verify whether a given JSON object satisfies a given JSON schema.
  • Constructor Details

  • Method Details

    • validateStrict

      public static boolean validateStrict​(Json objectToValidate, Json againstSchema)
      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

      public static boolean validate​(Json objectToValidate, Json againstSchema)
      A static equivalent of validateWithReasoning(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: JsonSchemaEnforceable
      Validate with the potential to throw exceptions to the caller.
      Specified by:
      validateWithReasoning in interface JsonSchemaEnforceable
      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.