▲ | 1718627440 3 days ago | |
But when you parse all arguments first before throwing error messages, you can create much better error messages, since they can be more holistic. To do that you need to represent the invalid configuration as a type. | ||
▲ | geon 2 days ago | parent | next [-] | |
Sure. Then you return that validated data structure from the parsing function and never touch the invalid data structure again. That's exactly what "Parse, don't validate" means. | ||
▲ | 12_throw_away 3 days ago | parent | prev [-] | |
> To do that you need to represent the invalid configuration as a type Right - and one thing that keeps coming up for me is that, if you want to maintain complex invariants, it's quite natural to express them in terms of the domain object itself (or maybe, ugh, a DTO with the same fields), rather than in terms of input constraints. |