From 8b552744661ce20360f6de2d0574d175756e7ca2 Mon Sep 17 00:00:00 2001 From: "Jeremy D. Miller" Date: Mon, 6 May 2024 15:27:50 -0500 Subject: [PATCH] Wolverine now considers a method named "Validate" or "ValidateAsync" to be a "before" method --- .../WolverineWebApi/Validation/ValidatedCompoundEndpoint.cs | 1 - .../CQRSWithMarten/TeleHealth.WebApi/ProviderShiftEndpoint.cs | 2 +- src/Wolverine/Middleware/MiddlewarePolicy.cs | 2 +- 3 files changed, 2 insertions(+), 3 deletions(-) diff --git a/src/Http/WolverineWebApi/Validation/ValidatedCompoundEndpoint.cs b/src/Http/WolverineWebApi/Validation/ValidatedCompoundEndpoint.cs index 40cb7f0b2..cc5532bdb 100644 --- a/src/Http/WolverineWebApi/Validation/ValidatedCompoundEndpoint.cs +++ b/src/Http/WolverineWebApi/Validation/ValidatedCompoundEndpoint.cs @@ -14,7 +14,6 @@ public class ValidatedCompoundEndpoint return new User(cmd.UserId); } - [WolverineBefore] public static IResult Validate(User user) { if (user == null) diff --git a/src/Samples/CQRSWithMarten/TeleHealth.WebApi/ProviderShiftEndpoint.cs b/src/Samples/CQRSWithMarten/TeleHealth.WebApi/ProviderShiftEndpoint.cs index 97e2b6f34..4c0d5bd85 100644 --- a/src/Samples/CQRSWithMarten/TeleHealth.WebApi/ProviderShiftEndpoint.cs +++ b/src/Samples/CQRSWithMarten/TeleHealth.WebApi/ProviderShiftEndpoint.cs @@ -35,7 +35,7 @@ public static class StartProviderShiftEndpoint return (board, provider, WolverineContinue.Result()); } - [WolverineBefore] + // Validate or ValidateAsync() is considered by Wolverine to be a "before" method public static IResult Validate(Provider provider, Board board) { // Check if you can proceed to add the provider to the board diff --git a/src/Wolverine/Middleware/MiddlewarePolicy.cs b/src/Wolverine/Middleware/MiddlewarePolicy.cs index 3f006ff02..0c7c371c9 100644 --- a/src/Wolverine/Middleware/MiddlewarePolicy.cs +++ b/src/Wolverine/Middleware/MiddlewarePolicy.cs @@ -13,7 +13,7 @@ namespace Wolverine.Middleware; public class MiddlewarePolicy : IChainPolicy { - public static readonly string[] BeforeMethodNames = ["Before", "BeforeAsync", "Load", "LoadAsync"]; + public static readonly string[] BeforeMethodNames = ["Before", "BeforeAsync", "Load", "LoadAsync", "Validate", "ValidateAsync"]; public static readonly string[] AfterMethodNames = ["After", "AfterAsync", "PostProcess", "PostProcessAsync"]; public static readonly string[] FinallyMethodNames = ["Finally", "FinallyAsync"];