Home Manual Reference Source Repository
import ValidationError from '@mapcreator/api/src/errors/ValidationError.js'
public class | source

ValidationError

Extends:

ErrorApiError → ValidationError

Extension of ApiError containing an extra field for validation errors

Constructor Summary

Public Constructor
public

constructor(params: Object)

Member Summary

Public Members
public get

True if the error contains schema errors

public get

Get validation error messages

public

Get the schema errors if available

public

Any validation errors

Method Summary

Public Methods
public

Inherited Summary

From class ApiError
public get

Returns if the error contained a stacktrace that has been parsed This should only be true if the API is in debug mode.

public

Get the request options

public

request: Request

Get the request

public

response: Response

Get the response

public

Http error code

public

trace: Array<{line: Number, file: String, code: String}>: *

Get the parsed stacktrace from the error

public

Error type

public

Display-able string

Public Constructors

public constructor(params: Object) source

Override:

ApiError#constructor

Params:

NameTypeAttributeDescription
params Object
params.options Object

Request options

params.data Object

Response data

params.request Request

Request

params.response Response

Response

Public Members

public get hasSchemaErrors: boolean: * source

True if the error contains schema errors

Return:

boolean

Has schema errors

public get messages: Array<String>: * source

Get validation error messages

Return:

Array<String>

All validation messages

public schemaErrors: SchemaError[] source

Get the schema errors if available

Example:

[
  {
    "property": "data.meta",
    "pointer": "/data/meta",
    "message": "The property meta is required",
    "constraint": {
      "name": "required",
      "params": {
        "property": "meta"
      }
    },
    "context": 1
  },
   {
    "property": "data.paper",
    "pointer": "/data/paper",
    "message": "The property paper is required",
    "constraint": {
      "name": "required",
      "params": {
        "property": "paper"
      }
    },
    "context": 1
  },
   {
    "property": "data.scaleDefinition",
    "pointer": "/data/scaleDefinition",
    "message": "The property scaleDefinition is required",
    "constraint": {
      "name": "required",
      "params": {
        "property": "scaleDefinition"
      }
    },
    "context": 1
  }
]

See:

public validationErrors: Object<String, Array<String>> source

Any validation errors

Public Methods

public toString(): string source

Display-able string

Override:

ApiError#toString

Return:

string