Let’s recap what we’ve achieved so far with our semantic types for validation. We’ve created a handful of types that work together to give a good model for capturing and processing object validation. The model starts with the base class ValidationResult
and its subclasses:
SuccessResult
handles the case when everything is fineErrorResult
handles a single errorAggregateResult
collects multiple other results together
The static class Validation
is a factory, giving us a simple way to create validation results:
With the operators +
, &
and &&
, we can easily combine validation results together in a fairly declarative fashion. For example, from the motivation post at the start of this series, we can rebuild one of the examples:
But … no project survives scope creep …
Now that we have a solid foundation, what might we add that makes validation easier and more powerful?
Comments
blog comments powered by Disqus