Skip to main content

Validation And Errors

This page documents the public C# API for validation and errors, generated from the XML documentation of the compiled library. Values are immutable, constructors take named arguments and validate them, and read-only properties return what was passed.

ErrorCategory​

Stable validation categories shared by every slackblocks implementation.

ToWireValue() returns the value Slack expects in JSON.

ConstantSlack valueMeaning
LengthExceededlength-exceededA string or collection falls outside Slack's documented length limits.
OutOfRangeout-of-rangeA numeric value falls outside Slack's documented range.
MutuallyExclusivemutually-exclusiveTwo fields that cannot coexist were supplied together.
TypeMismatchtype-mismatchA value is not an accepted Slack object or scalar type.
MissingRequiredmissing-requiredA required field or collection is absent.
InvalidUsageinvalid-usageA combination of otherwise valid values cannot be used together.

ValidationException​

Thrown when a slackblocks value would break a Slack Block Kit rule.

This derives from ArgumentException, so code that already handles invalid arguments continues to work. Catch ValidationException when you need the stable ValidationException.Category or the ValidationException.Path of the invalid field. Paths start with the type being constructed, for example SectionBlock.fields[2].text.

ValidationException​

Creates a structured validation failure.

public ValidationException(ErrorCategory category, string path, string reason)
ParameterDescription
categoryStable cross-language failure category.
pathDotted path of the invalid value.
reasonHuman-readable explanation.

Related types: ErrorCategory, ValidationException

Category​

Gets the stable cross-language error category.

public ErrorCategory Category { get; }

Related types: ErrorCategory

Path​

Gets the dotted path of the invalid field, starting with the type being constructed.

public string Path { get; }