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()`. Note that invoking `validateAsync(Object)` generally doesn't have any additional overhead than invoking `validateSync(Object)`.
  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
    --- | ---
    `Object` | `getJson()`
    `JsonPointer` | `getScope()`
    `boolean` | `isSync()`
    `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.

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

      Parameters:
        `json` - input to validate
      Returns:
        a failed future with `ValidationException` if json doesn't match the schema, otherwise a succeeded future.

    - #### 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` - input to validate
      Throws:
        `ValidationException` - if the input doesn't match the schema
        `NoSyncValidationException` - If the schema cannot perform a synchronous validation

    - #### getScope

          JsonPointer getScope()

      Returns:
        scope of this schema

    - #### getJson

          Object getJson()

      Returns:
        Json representation of the schema

    - #### isSync

          boolean isSync()

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

Copyright © 2021 Eclipse. All rights reserved.