Skip to content

Commit 8dfc91b

Browse files
committed
More updated
1 parent a403939 commit 8dfc91b

File tree

1 file changed

+10
-5
lines changed

1 file changed

+10
-5
lines changed

README.md

Lines changed: 10 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -33,7 +33,7 @@ services.AddMediator();
3333

3434
## 🧩 Simple Handler Example
3535

36-
Just add a class ending with `Handler` or `Consumer` static or instance. Methods must be named `Handle(Async)` or `Consume(Async)`. Supports multiple handler methods in a single class—for example, a `UserHandler` containing all CRUD methods.
36+
Just add a class (instance or static) ending with `Handler` or `Consumer`. Methods must be named `Handle(Async)` or `Consume(Async)`. Supports multiple handler methods in a single class—for example, a `UserHandler` containing all CRUD methods.
3737

3838
```csharp
3939
public record Ping(string Text);
@@ -75,10 +75,15 @@ Discovered by convention; static or instance:
7575
```csharp
7676
public static class ValidationMiddleware
7777
{
78-
public static HandlerResult Before(object msg)
79-
=> MiniValidator.TryValidate(msg, out var errs)
80-
? HandlerResult.Continue()
81-
: HandlerResult.ShortCircuit(Result.Invalid(errs));
78+
public static HandlerResult Before(object msg) {
79+
if (!TryValidate(msg, out var errors))
80+
{
81+
// implictly converted to Result<T>
82+
return HandlerResult.ShortCircuit(Result.Invalid(errors));
83+
}
84+
85+
return HandlerResult.Continue();
86+
}
8287
}
8388
```
8489

0 commit comments

Comments
 (0)