Hacker Newsnew | past | comments | ask | show | jobs | submitlogin



I think you may have misunderstood the article.

The point of the article is to parse AND validate input AT THE BOUNDARY between the outside world and your program, rather than a bunch of ad-hoc validations at various points after the suspect data has entered the castle walls and has already been (at least partially) processed (thus making the program state harder to reason about). By enforcing your invariants at the border, you ensure that all data entering your system always conforms to your expectations, just like a strong type system ensures that invalid states are not representable. A schema is basically a type system for your raw data.

This concept is also a major element of Domain Driven Design https://en.wikipedia.org/wiki/Domain-driven_design


Great to see this article, I totally agreed with the view that rejecting any invalid case by designing the right data structure.

Unfortunately, it is hard to achieve it in practice and people even don't realize this, JSON Object is a good example, Human are incline expecting the duplicated key is not allowed in JSON, but it happens.

For this goal, I think the Protobuf is good way to eliminate the possible invalid data for data transportation.




Consider applying for YC's Summer 2026 batch! Applications are open till May 4

Guidelines | FAQ | Lists | API | Security | Legal | Apply to YC | Contact

Search: