Validating with Validations
Getting back to validating the name for a to-do list, how can we combine these functions? What we want is to apply each of them to the same input, and then combine all the errors together, or return success if there isn’t any error.
Combining errors is something that we haven’t done yet. Every time we’ve looked at Outcome, we’ve concentrated on the success case, which is more natural. Still, there are cases like this one where we don’t particularly care for the successful result, and instead we want to focus on error composition.
How can we write such a function in a generic way? A useful technique in functional programming is writing the function with the signature we want and then trying to implement it and seeing ...
Become an O’Reilly member and get unlimited access to this title plus top books and audiobooks from O’Reilly and nearly 200 top publishers, thousands of courses curated by job role, 150+ live events each month,
and much more.
Read now
Unlock full access