Created
September 17, 2022 00:15
-
-
Save benjaminvanrenterghem/ef9b7de338dff5b4de73f74fc32b545f to your computer and use it in GitHub Desktop.
ValidationBehavior Cancellation Snippet
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
// ... | |
// #1 Indien het aantal validatiefouten groter is dan 0 dan retourneert de ValidationBehavior zelf een Response | |
// en worden latere Behaviors en de Handler niet bereikt | |
if (failures.Count > 0) { | |
var result = new TResponse(); | |
result.Messages = failures.Select(f => | |
new Message { | |
Body = f.ErrorMessage, | |
MessageType = MessageType.Error | |
} | |
).ToList(); | |
result.Messages.Add(new Message { Body = "Validation failed, check your request", MessageType = MessageType.Info }); | |
return result; | |
} | |
// ... |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment