Table of Contents

Interface IValidatorResolver

Namespace
Excalibur.Dispatch.Validation
Assembly
Excalibur.Dispatch.dll

Provides message validation resolution services for the dispatch system. Resolves and executes appropriate validators based on message type and content.

public interface IValidatorResolver
Extension Methods

Methods

TryValidateAsync(IDispatchMessage, IServiceProvider?, CancellationToken)

Attempts to validate the specified message using registered validators. Returns validation results if validators are available for the message type, or null if no validation is required.

ValueTask<IValidationResult?> TryValidateAsync(IDispatchMessage message, IServiceProvider? requestServices = null, CancellationToken cancellationToken = default)

Parameters

message IDispatchMessage

The message to validate.

requestServices IServiceProvider

The caller-owned request-scoped provider, when available.

cancellationToken CancellationToken

Cancellation of validation.

Returns

ValueTask<IValidationResult>

A IValidationResult containing validation outcomes if validators exist; otherwise, null if no validation is needed for the message type.

Remarks

Borrowed request services take precedence over ambient services and are never disposed by the resolver. A resolver requiring services creates and asynchronously disposes its own scope when neither is available. Validation failures are returned; cancellation and infrastructure exceptions propagate.