Options
All
  • Public
  • Public/Protected
  • All
Menu

Class 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 and
  • Asynchronous: One or more branches of the validator tree requires an asynchronous validation, so you must use to validate your json. If you use it will throw a {@link NoSyncValidationException}

To check the schema state you can use method . Note that invoking {@link Schema#validateAsync} generally doesn't have any additional overhead than invoking {@link Schema#validateSync}.
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

Hierarchy

  • Schema

Index

Methods

getJson

  • getJson(): any
  • Returns any

getScope

  • getScope(): JsonPointer
  • Returns JsonPointer

isSync

  • isSync(): boolean
  • Returns boolean

validateAsync

  • validateAsync(json: any): PromiseLike<void>
  • Validate the json performing an asynchronous validation.

    Note: If the schema is synchronous, this method will call internally

    Parameters

    • json: any

    Returns PromiseLike<void>

validateSync

  • validateSync(json: any): void
  • Validate the json performing a synchronous validation. Throws a {@link ValidationException} if json doesn't match the schema.

    Parameters

    • json: any

    Returns void

Generated using TypeDoc