Skip to content
scoop
Back to your scoops
Hacker News: Front Pagefagnerbrack6w ago

Parse, Don't Validate – In a Language That Doesn't Want You To

The scoop

A TypeScript developer advocates for the "parse, don't validate" principle, where parsers encode validation results into distinct types using branded types rather than just boolean checks. This prevents redundant validation scattered throughout code, though TypeScript's structural typing makes the approach less ergonomic than in languages like Haskell. Reader notes the challenge of handling optional fields without proliferating types.

Read the originalDiscussion
How was this scoop?