Options
All
  • Public
  • Public/Protected
  • All
Menu

Class DataTransferObject

Creates a new data transfer object which will validate and reshape its input data based on the validators of its own properties. Must be extended, should not be instantiated on its own.

Hierarchy

  • DataTransferObject

Index

Constructors

constructor

Properties

Private Optional __@ongoingValidation@24355

__@ongoingValidation@24355: undefined | Promise<ValidationError[]>

Pending validation promise, if any.

Private __@validated@24354

__@validated@24354: boolean = false

Whether this object has already been validated.

Private __@validationErrors@24352

__@validationErrors@24352: ValidationError[] = ...

Cached validation errors from previous validation.

Methods

getValidationErrors

getValidationErrorsAsync

  • Runs all synchronous and asynchronous validators on this object. Always returns a promise. To validate synchronously, use .getValidationErrors().

    Parameters

    Returns Promise<ValidationError[]>

toJSON

validate

  • Validates this object (sync validators only), and returns its plain data if validations pass. Otherwise, throws an error or runs the appropriate handler set with setValidationErrorHandler().

    To run both sync and async validators, use .validateAsync().

    Parameters

    Returns Pick<DataTransferObject, never>

validateAsync

  • Validates this object asynchronously, and resolves to its plain data if validations pass. Otherwise, rejects with an error or runs the appropriate handler set with setValidationErrorHandler().

    To validate synchronously, use .validate().

    Parameters

    Returns Promise<Pick<DataTransferObject, never>>

Generated using TypeDoc