Path: redb-route/redb.Route/Validation/IMessageValidator.cs Snapshot: redb-route, development snapshot 2026-12-06. This is the development state of the public mirrors; it may differ from the published packages. License: Apache-2.0. Repository: https://github.com/redbase-app/redb-route Page: https://redbase.app/src/dev-2026-12-06/redb-route/redb.Route/Validation/IMessageValidator.cs ---- using redb.Route.Abstractions; namespace redb.Route.Validation; /// /// Result of a message validation operation. /// public sealed class ValidationResult { /// Whether the validation passed. public bool IsValid { get; } /// Human-readable error messages (empty when valid). public IReadOnlyList Errors { get; } /// /// Severity for failures. Defaults to for backward /// compatibility. Adapters that produce non-blocking diagnostics may set /// . /// public ValidationSeverity Severity { get; } private ValidationResult(bool isValid, IReadOnlyList errors, ValidationSeverity severity) { IsValid = isValid; Errors = errors; Severity = severity; } /// Creates a successful validation result. public static ValidationResult Success() => new(true, Array.Empty(), ValidationSeverity.Error); /// Creates a failed validation result with one or more errors. /// Validation error messages. public static ValidationResult Failure(IReadOnlyList errors) => new(false, errors, ValidationSeverity.Error); /// Creates a failed validation result with a single error message. /// Validation error message. public static ValidationResult Failure(string error) => new(false, new[] { error }, ValidationSeverity.Error); /// Creates a failed validation result with explicit severity. /// Validation error messages. /// Severity classification. public static ValidationResult Failure(IReadOnlyList errors, ValidationSeverity severity) => new(false, errors, severity); } /// /// Contract for message validators. Validates the exchange body (or a specific part of it) /// and returns a structured . /// /// Implementations include JSON Schema validation, XSD validation, and custom predicate-based validation. /// /// public interface IMessageValidator { /// /// Validates the exchange asynchronously. The default forwards to ; /// a validator that has to consult a store or a service overrides this one, and the /// processor awaits it. /// /// The exchange to validate. /// A task yielding the validation result. Task ValidateAsync(IExchange exchange) => Task.FromResult(Validate(exchange)); /// /// Validates the exchange and returns a result indicating success or failure with error details. /// /// The exchange to validate. /// A with validation outcome and any errors. ValidationResult Validate(IExchange exchange); }