Skip to content

Commit

Permalink
Wolverine now considers a method named "Validate" or "ValidateAsync" …
Browse files Browse the repository at this point in the history
…to be a "before" method
  • Loading branch information
jeremydmiller committed May 6, 2024
1 parent 63691a1 commit 8b55274
Show file tree
Hide file tree
Showing 3 changed files with 2 additions and 3 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -14,7 +14,6 @@ public class ValidatedCompoundEndpoint
return new User(cmd.UserId);
}

[WolverineBefore]
public static IResult Validate(User user)
{
if (user == null)
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down
2 changes: 1 addition & 1 deletion src/Wolverine/Middleware/MiddlewarePolicy.cs
Original file line number Diff line number Diff line change
Expand Up @@ -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"];

This comment has been minimized.

Copy link
@igor-toporet

igor-toporet May 10, 2024

Contributor

do those get executed in this exact order? or they're here in alphabetical order coincidentally?

cause if a handler has both Load and Validate can we count that Load will be executed first?

also, I hope sync/async versions can be mixed and matched. most likely the Load will be async (LoadAsync), while Validate most likely synchronous, just in-memory/in-process validation without requiring any IO.

This comment has been minimized.

Copy link
@igor-toporet

igor-toporet May 10, 2024

Contributor

Also, I have a question: What's the release (to Nuget) schedule/cadence typically? I'd use this one asap.

public static readonly string[] AfterMethodNames = ["After", "AfterAsync", "PostProcess", "PostProcessAsync"];
public static readonly string[] FinallyMethodNames = ["Finally", "FinallyAsync"];

Expand Down

0 comments on commit 8b55274

Please sign in to comment.