Skip to main content
Version: 2.2.0

Class: ValidationError

An error thrown to indicate that a name fails the validation rules.

Extends​

Constructors​

Constructor​

new ValidationError(error): ValidationError

Creates error containing the invalid nameType and a message that briefly describes the problem if provided.

For example, a validation error can be interpreted as: "ValidationError (nameType='stringName')", "ValidationError (nameType='stringName'): message"

Parameters​

error​

ErrorMessage & object

Returns​

ValidationError

Overrides​

NameError.constructor

Properties​

cause?​

optional cause?: unknown

Inherited from​

NameError.cause


message​

message: string

Inherited from​

NameError.message


name​

name: string

Inherited from​

NameError.name


nameType​

readonly nameType: string

Name of the invalid nameType if available.


source​

readonly source: string | string[]

Inherited from​

NameError.source


stack?​

optional stack?: string

Inherited from​

NameError.stack


type​

readonly type: NameErrorType

Inherited from​

NameError.type

Accessors​

hasMessage​

Get Signature​

get hasMessage(): boolean

Whether a message describing the failure exists.

Returns​

boolean

Inherited from​

NameError.hasMessage


sourceAsString​

Get Signature​

get sourceAsString(): string

The actual source input which caused the error.

Returns​

string

Inherited from​

NameError.sourceAsString

Methods​

toString()​

toString(): string

Returns a string representation of the error.

Returns​

string

Overrides​

NameError.toString