3 ms·
What a strange coincidence -- I was working on this exact same problem with a small validation library for a project, when I took a break to read Hacker News.
by jordanlev 12y ago
What a strange coincidence -- I was working on this exact same problem with a small validation library for a project, when I took a break to read Hacker News.
I feel so smart right now because Martin Fowler validated (no pun intended!) my own thinking on this issue.
Both conceptually (a form validation error is not exceptional -- it is expected behavior that you want to handle within the flow of your program), and practically (throwing exceptions makes it harder to display multiple errors for the same field, so the user winds up playing "whack-a-mole" when there are a lot of different rules... e.g. "password must be at least 6 characters", "password must contain a letter and a number", etc.)