ErrorList #462
Replies: 5 comments 1 reply
-
Thank you, this is going to be a good reference point. I'll let you know once I start working on this, so that you can review the implementation. |
Beta Was this translation helpful? Give feedback.
-
I also wrote a base controller The library converts CSharpFunctionalExtensions.Result to HTTP errors but using the base controller Run the sample program to try it out. Example: public ActionResult<AuthenticationResult> Register(RegisterRequest request) =>
Domain.User.Create(request.firstName, request.lastName, request.email, request.password)
.Bind(user => Result.Success<AuthenticationResult, ErrorList>(new AuthenticationResult(user, "token")))
.Finally(authResult => MapToOkObjectResult(authResult)); If a validation failure occurs, it will return a response like
{
"type": "https://tools.ietf.org/html/rfc7231#section-6.5.1",
"title": "One or more validation errors occurred.",
"status": 400,
"traceId": "00-19b910c84bc8651a1c6d26e9ee640813-59f0f7943ce1d3ab-00",
"errors": {
"lastName": [
"The lastName field is required."
],
"firstName": [
"The firstName field is required."
]
}
} |
Beta Was this translation helpful? Give feedback.
-
I updated the package so there is no longer the need to derive from my base controller, instead use the extension method public ActionResult<AuthenticationResult> Register(RegisterRequest request) =>
Domain.User.Create(request.firstName, request.lastName, request.email, request.password)
.Bind(user => Result.Success<AuthenticationResult, ErrorList>(new AuthenticationResult(user, "token")))
.ToActionResult(this); https://www.nuget.org/packages/CSharpFunctionalExtensions.Asp/0.1.0-alpha.5 |
Beta Was this translation helpful? Give feedback.
-
I have dealt with the same issue a year ago, but wanted a single Error class to handle this transparently. Basically a quick and dirty variation on what @xavierjohn provided : @vkhorikov Any eta on v3 ? Was it already decided if the Error class will become a part of the library ? |
Beta Was this translation helpful? Give feedback.
-
I took a different approach of only using a collection with AggregatedError and ValidationError. The v1 version of the library is out https://www.nuget.org/packages/FunctionalDDD.RailwayOrientedProgramming/1.0.1 since the first service using it has shipped to production. |
Beta Was this translation helpful? Give feedback.
-
I created a nuget package that will help return errors as a collection.
I have also posted a sample code of how I think fluent validation can be leveraged in Domain which is different from the idea presented in the Pluralsite course.
Let me know your thoughts.
https://www.nuget.org/packages/CSharpFunctionalExtensions.Errors/0.0.0.1-alpha
Beta Was this translation helpful? Give feedback.
All reactions