Repository navigation
Extension FluentValidation
Stateflows.Extensions.FluentValidation connects FluentValidation validators to Stateflows' event validation pipeline. FluentValidation errors are converted into System.ComponentModel.DataAnnotations.ValidationResult values, so an invalid event follows the normal Stateflows validation behavior.
Install the extension and register it along with your FluentValidation validators:
using FluentValidation;
using Stateflows;
services.AddStateflows(stateflows => stateflows
.AddFluentValidation()
.AddStateMachines(machines => machines
.AddStateMachine<Order>()));
services.AddSingleton<IValidator<ConfirmOrder>, ConfirmOrderValidator>();Validators are resolved from dependency injection by the exact event type being validated. If no validator is registered for that type, this extension contributes no FluentValidation errors. For a structural event, it can also resolve an IValidator<StructuralEvent> when no validator is registered for a more specific CLR event type.
public sealed record ConfirmOrder(string Email);
public sealed class ConfirmOrderValidator : AbstractValidator<ConfirmOrder>
{
public ConfirmOrderValidator()
{
RuleFor(order => order.Email).EmailAddress();
}
}Register FluentValidation services in the same service collection used by Stateflows. Other Stateflows validators may also participate in validation; this extension adapts FluentValidation results rather than replacing the core validation pipeline. See the project source.
Home page Support Code licensed under an MIT-style License. Documentation licensed under CC BY 4.0. © by Mikołaj Milewski, 2026
Overview
Installation
Runtimes
Orleans runtime
Concepts
Events and Structural Events
Messaging Patterns
Validation
Scheduling
Observability
Behaviors
Behavior Values
Dependency Injection
Behavioral Groups
State Machines
Concepts
State Identity
In-State Event Deferrals
Evaluation of Transitions
Exception Handling
Building blocks
Regions
States
State
Composite State
Orthogonal State
Final State
Pseudostates
Choice
Junction
Fork
Join
History
Transitions
Transition
Default Transition
Internal Transition
Activities
Concepts
Exception Handling
Implicit Fork and Join
Tokens
Building blocks
Nodes
Action Node
Decision Node
Merge Node
Initial Node
Final Node
Input Node
Output Node
Fork Node
Join Node
Accept Event Action Node
Send Event Action Node
Publish Event Action Node
Time Event Action Node
Data Store Node
Structured Activity Node
Iterative Activity Node
Parallel Activity Node
Flows
Data Flow
Control Flow
Actions
Entities
Fields
Mutations
Projections
Extensions
ClearScript
FluentValidation
JSON definitions
Minimal APIs
OneOf
OpenTelemetry
PlantUML
Scheduling