Doorkeeper is a wrapper for AJV that allows us to validate JSONs against schemas. It also allows us to register schemas and retrieve them later.

Type Parameters

  • T = void

Constructors

Properties

Doorkeeper options

uuid: string = ...

Methods

  • Try to validate an Object against the input schema or throw a ValidationError

    Type Parameters

    • K extends string

    Parameters

    • schema: K

      The schema we want to validate

    • data: any

      Object to be validated

    Returns ValidatedOutput<T, K>

  • Try to validate an Object against the input schema or throw a ValidationError

    Type Parameters

    • K extends string

    Parameters

    • schema: K

      The schema we want to validate

    • data: any

      Object to be validated

    • uuid: string

      unique identifier for this operation

    Returns ValidatedOutput<T, K>

  • Validate an Object against the input schema and return a boolean

    Type Parameters

    • K extends string

    Parameters

    • schema: K

      The schema we want to validate

    • data: any

      Object to be validated

    Returns boolean

  • Validate an Object against the input schema and return a boolean

    Type Parameters

    • K extends string

    Parameters

    • schema: K

      The schema we want to validate

    • data: any

      Object to be validated

    • uuid: string

      unique identifier for this operation

    Returns boolean

  • Experimental

    Return a dereferenced schema with all the $ref resolved

    Type Parameters

    • K extends string

    Parameters

    • schema: K

      The schema we want to dereference

    • uuid: string = ...

      unique identifier for this operation

    Returns AnySchema

    A dereferenced schema with all the $ref resolved This method is experimental and might change in the future without notice or be removed from a future release. Use it at your own risk.

  • Checks if the given data matches the specified schema.

    Type Parameters

    • K extends string

    Parameters

    • schema: K

      The schema to check against.

    • data: any

      The data to validate.

    Returns data is ValidatedOutput<T, K>

    A boolean indicating whether the data matches the schema.

  • Checks if the input schema is registered

    Type Parameters

    • K extends string

    Parameters

    • schema: K

      schema asked for

    Returns boolean

    • if the schema is registered in the ajv collection
  • Registers a group of schemas from an object using the keys of the object as key and the value as the validation schema

    Parameters

    • schemas: Record<SchemaSelector<T>, AnySchema>

      Object containing the [key, validation schema]

    Returns DoorKeeper<T>

    • the instance
  • Registers a group of schemas from an array and compiles them

    Parameters

    • schemas: AnySchema[]

      Array containing the

    Returns DoorKeeper<T>

    • the instance
  • Registers one schema with its key

    Parameters

    • key: SchemaSelector<T>

      the key with which identify the schema

    • validatorSchema: AnySchema

      the schema to be registered

    Returns DoorKeeper<T>

    • the instance
  • Validate an Object against the input schema

    Type Parameters

    • K extends string

    Parameters

    • schema: K

      The schema we want to validate

    • data: any

      Object to be validated

    • uuid: string

      unique identifier for this operation

    • callback: ResultCallback<T, K>

      callback function with the result of the validation

    Returns void

  • Validate an Object against the input schema

    Type Parameters

    • K extends string

    Parameters

    • schema: K

      The schema we want to validate

    • data: any

      Object to be validated

    • callback: ResultCallback<T, K>

      callback function with the result of the validation

    Returns void

  • Validate an Object against the input schema

    Type Parameters

    • K extends string

    Parameters

    • schema: K

      The schema we want to validate

    • data: any

      Object to be validated

    • uuid: string

      unique identifier for this operation

    Returns Promise<ValidatedOutput<T, K>>

  • Validate an Object against the input schema

    Type Parameters

    • K extends string

    Parameters

    • schema: K

      The schema we want to validate

    • data: any

      Object to be validated

    Returns Promise<ValidatedOutput<T, K>>