Skip to main content

Errors

Typed validation errors returned by eager construction and explicit validation.

ErrorCategory

ErrorCategory = "length-exceeded" | "out-of-range" | "mutually-exclusive" | "type-mismatch" | "missing-required" | "invalid-usage"

Stable machine-readable category attached to every validation error.


InvalidUsageError

Base class for invalid Block Kit input.

Catch this class to handle every slackblocks validation failure, or catch a subclass when the reason matters to application behavior.

Extends

  • Error

Extended by

Constructors

Constructor

new InvalidUsageError(path, message): InvalidUsageError

Creates a validation error.

Parameters
ParameterTypeDescription
pathstringDot-and-index path to the invalid field.
messagestringHuman-readable explanation of the constraint.
Returns

InvalidUsageError

Overrides

Error.constructor

Properties

PropertyModifierTypeDefault valueDescription
categoryreadonlyErrorCategory"invalid-usage"Machine-readable failure category.
pathreadonlystringundefinedDot-and-index path to the invalid payload field.

LengthError

A string, array, or collection exceeded an allowed minimum or maximum length.

Extends

Constructors

Constructor

new LengthError(path, message): LengthError

Creates a validation error.

Parameters
ParameterTypeDescription
pathstringDot-and-index path to the invalid field.
messagestringHuman-readable explanation of the constraint.
Returns

LengthError

Inherited from

InvalidUsageError.constructor

Properties

PropertyModifierTypeDescriptionOverrides
categoryreadonly"length-exceeded"Machine-readable failure category.InvalidUsageError.category
pathreadonlystringDot-and-index path to the invalid payload field.-

MissingRequiredError

A required field or one-of requirement was not satisfied.

Extends

Constructors

Constructor

new MissingRequiredError(path, message): MissingRequiredError

Creates a validation error.

Parameters
ParameterTypeDescription
pathstringDot-and-index path to the invalid field.
messagestringHuman-readable explanation of the constraint.
Returns

MissingRequiredError

Inherited from

InvalidUsageError.constructor

Properties

PropertyModifierTypeDescriptionOverrides
categoryreadonly"missing-required"Machine-readable failure category.InvalidUsageError.category
pathreadonlystringDot-and-index path to the invalid payload field.-

MutualExclusivityError

Fields that cannot be used together were both supplied.

Extends

Constructors

Constructor

new MutualExclusivityError(path, message): MutualExclusivityError

Creates a validation error.

Parameters
ParameterTypeDescription
pathstringDot-and-index path to the invalid field.
messagestringHuman-readable explanation of the constraint.
Returns

MutualExclusivityError

Inherited from

InvalidUsageError.constructor

Properties

PropertyModifierTypeDescriptionOverrides
categoryreadonly"mutually-exclusive"Machine-readable failure category.InvalidUsageError.category
pathreadonlystringDot-and-index path to the invalid payload field.-

OutOfRangeError

A numeric value fell outside its allowed range.

Extends

Constructors

Constructor

new OutOfRangeError(path, message): OutOfRangeError

Creates a validation error.

Parameters
ParameterTypeDescription
pathstringDot-and-index path to the invalid field.
messagestringHuman-readable explanation of the constraint.
Returns

OutOfRangeError

Inherited from

InvalidUsageError.constructor

Properties

PropertyModifierTypeDescriptionOverrides
categoryreadonly"out-of-range"Machine-readable failure category.InvalidUsageError.category
pathreadonlystringDot-and-index path to the invalid payload field.-

TypeMismatchError

A payload field or nested object has the wrong runtime type.

Extends

Constructors

Constructor

new TypeMismatchError(path, message): TypeMismatchError

Creates a validation error.

Parameters
ParameterTypeDescription
pathstringDot-and-index path to the invalid field.
messagestringHuman-readable explanation of the constraint.
Returns

TypeMismatchError

Inherited from

InvalidUsageError.constructor

Properties

PropertyModifierTypeDescriptionOverrides
categoryreadonly"type-mismatch"Machine-readable failure category.InvalidUsageError.category
pathreadonlystringDot-and-index path to the invalid payload field.-