Skip to content

Instantly share code, notes, and snippets.

Show Gist options
  • Save benjaminvanrenterghem/ef9b7de338dff5b4de73f74fc32b545f to your computer and use it in GitHub Desktop.
Save benjaminvanrenterghem/ef9b7de338dff5b4de73f74fc32b545f to your computer and use it in GitHub Desktop.
ValidationBehavior Cancellation Snippet
// ...
// #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