Skip to main content

Errors

Typed validation errors raised while builders materialize or explicit payload validation runs. Every subclass includes a machine-readable category and a path identifying the invalid field.

ErrorCategory

type 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 falls outside a field's allowed length. Typical causes include text exceeding Slack's limit, too many options, or an action identifier longer than 255 characters.

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 is not satisfied. Typical causes include building a section without text or fields, or creating a conversation filter without any filter options.

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

Mutually exclusive fields are supplied together. Examples include combining an image URL with a Slack file, or providing both options and option groups to a static select menu.

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 falls outside a field's allowed range. Typical causes include minimum values greater than maximum values or counts outside Slack's supported bounds.

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 or an unsupported discrete value. The error path identifies the exact field that failed runtime validation.

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.-