Skip to main content

Validation and Errors

Generated from actual PHP reflection and PHPDoc. Names live in the Slackblocks namespace. Use named arguments and declare(strict_types=1); values validate before construction returns.

ErrorCategory​

Stable validation categories shared by every Slackblocks implementation.

ConstantSlack valueMeaning
LengthExceeded'length-exceeded'Text length or collection size is outside its allowed bounds.
OutOfRange'out-of-range'A numeric value or page index is outside its allowed range.
MutuallyExclusive'mutually-exclusive'Fields violate an exclusive-choice requirement.
TypeMismatch'type-mismatch'A value has the wrong type, shape, vocabulary or serialization context.
MissingRequired'missing-required'A required field or required content is absent.
InvalidUsage'invalid-usage'Individually typed values violate a dependency or composition rule.

$name​

PHP case name, as declared in the enum.

public readonly string $name;

$value​

Slack wire string represented by this case.

public readonly string $value;

cases​

Returns every enum case in declaration order.

public static function cases(): array

Returns: list<ErrorCategory> Declared cases.

from​

Resolves a Slack wire string to its enum case, throwing if it is unknown.

public static function from(string|int $value): static
ParameterDescription
valueSlack wire string to resolve.

Returns: ErrorCategory Matching case.

ThrowsWhen
ValueErrorThe wire string has no matching case.

tryFrom​

Resolves a Slack wire string to its enum case, returning null if it is unknown.

public static function tryFrom(string|int $value): ?static
ParameterDescription
valueSlack wire string to resolve.

Returns: ErrorCategory|null Matching case.

ValidationError​

Invalid Slack content, with a stable category and a wire-field path.

$category​

Stable shared classification of the validation failure.

public readonly ErrorCategory $category;

Related types: ErrorCategory

$path​

Failing wire-field path, including collection indexes when applicable.

public readonly string $path;

__construct​

Describes a validation failure without losing its machine-readable category/path.

public function __construct(ErrorCategory $category, string $path, string $message)
ParameterDescription
categoryErrorCategory — Stable shared classification of the failure.
pathstring — Failing wire-field path, including collection indexes when applicable.
messagestring — Human-readable explanation of the violated rule.

Related types: ErrorCategory