io.vertx.json.schema

## Interface Schema

- All Known Subinterfaces:
    SchemaInternal
  All Known Implementing Classes:
    FalseSchema, RecursiveRefSchema, RefSchema, SchemaImpl, TrueSchema

      public interface Schema

  Interface representing a Json Schema

  A schema could have two states:

  - Synchronous: The validators tree can provide a synchronous validation, so you can validate your json both using `this#validateSync(Object)` and `this#validateAsync(Object)`
  - Asynchronous: One or more branches of the validator tree requires an asynchronous validation, so you must use `this#validateAsync(Object)` to validate your json. If you use `this#validateSync(Object)` it will throw a `NoSyncValidationException`

  To check the schema state you can use method `this#isSync()`
  The schema can mutate the state in time, e.g. if you have a schema that is asynchronous because of a `$ref`, after the first validation the external schema is cached inside `SchemaRouter` and this schema will switch to synchronous state

- - ### Method Summary

    All Methods Instance Methods Abstract Methods
    Modifier and Type | Method and Description
    --- | ---
    `void` | `applyDefaultValues(JsonArray array)` This function mutates `array` applying default values, when available.
    `void` | `applyDefaultValues(JsonObject object)` This function mutates `object` applying default values, when available.
    `Object` | `getDefaultValue()` Return the default value defined in the schema
    `Object` | `getJson()` Get Json representation of the schema
    `JsonPointer` | `getScope()` Get scope of this schema
    `boolean` | `hasDefaultValue()` Return true if the schema has a default value defined
    `boolean` | `isSync()` Returns true if this validator can actually provide a synchronous validation
    `Future<Void>` | `validateAsync(Object json)` Validate the json performing an asynchronous validation.
    `void` | `validateSync(Object json)` Validate the json performing a synchronous validation.

- - ### Method Detail

    - #### validateAsync

          Future<Void> validateAsync(Object json)

      Validate the json performing an asynchronous validation. Returns a failed future with `ValidationException` if json doesn't match the schema.

      Note: If the schema is synchronous, this method will call internally `this#validateSync(Object)`

      Parameters:
        `json` -
      Returns:

    - #### validateSync

          void validateSync(Object json)
                     throws ValidationException,
                            NoSyncValidationException

      Validate the json performing a synchronous validation. Throws a `ValidationException` if json doesn't match the schema.
      Parameters:
        `json` -
      Throws:
        `ValidationException`
        `NoSyncValidationException` - If the schema cannot perform a synchronous validation

    - #### getScope

          JsonPointer getScope()

      Get scope of this schema
      Returns:

    - #### getJson

          Object getJson()

      Get Json representation of the schema
      Returns:

    - #### getDefaultValue

          Object getDefaultValue()

      Return the default value defined in the schema
      Returns:

    - #### hasDefaultValue

          boolean hasDefaultValue()

      Return true if the schema has a default value defined
      Returns:

    - #### applyDefaultValues

          void applyDefaultValues(JsonArray array)
                           throws NoSyncValidationException

      This function mutates `array` applying default values, when available.
      Parameters:
        `array` -
      Throws:
        `NoSyncValidationException` - if this schema represents a `$ref` not solved yet

    - #### applyDefaultValues

          void applyDefaultValues(JsonObject object)
                           throws NoSyncValidationException

      This function mutates `object` applying default values, when available.
      Parameters:
        `object` -
      Throws:
        `NoSyncValidationException` - if this schema represents a `$ref` not solved yet

    - #### isSync

          boolean isSync()

      Returns true if this validator can actually provide a synchronous validation
      Returns:

Copyright © 2021 Eclipse. All rights reserved.