Support for multiple validation errors #314 #315
Merged
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
Resolves #314
This PR adds support for multiple validation errors.
Here are some interesting points about this implementation.
Option
andValueOption
to alist
.string list
. This means that the order of errors matters. I think that is reasonable.Submit
message in the sample no longer takes in the parsed data. However, doing so is preferred. As Mark Seemann recently said, validation is a solve problem via applicative functors. Unfortunately, F# doesn't include aValidation<,>
monad. I have created one in my project at work. I could add that to the sample but that would also increase the learning curve. Alternatively, one could just parse the input under the assumption it will succeed (viaint
) because thecanExec
function returnedtrue
. This is not a good practice to do everywhere though.