Class ValidationError

Represents a validation error that occurs when the input data does not conform to a specified schema.

This class extends the ClientError class and is used to handle HTTP 400 Bad Request errors resulting from invalid input.

ValidationError

Hierarchy (view full)

Constructors

Properties

code: number = 400

The HTTP status code representing a validation error.

message: string
name: string
stack?: string
prepareStackTrace?: ((err: Error, stackTraces: CallSite[]) => any)

Optional override for formatting stack traces

stackTraceLimit: number

Methods

  • Serializes the error details into an array of BaseServiceError objects.

    This method maps over the validation error details to create a structured response for each validation error, including the status code, type, message, path of the invalid input, and additional details.

    Returns BaseServiceError[]

    An array of serialized error details for each validation error, which includes:

    • code: 400 (Bad Request)
    • type: "ValidationError" (the name of the error class)
    • message: A user-friendly message indicating the validation issue.
    • path: An array showing the specific path of the invalid input.
    • details: An array containing additional information about the error.
  • Create .stack property on a target object

    Parameters

    • targetObject: object
    • OptionalconstructorOpt: Function

    Returns void