News for hackers. Stuff that matters.
Re:Parse, Don't Validate (2019) by thfuran on Tuesday February 10, 2026 @12:04PM (#46962988)
>But the context this type of an alias should exist in is one where a string isn't turned into a PhoneNumber until you've validated it.

Even if you don't do any validation as part of the construction (and yeah, having a separate type for validated vs unvalidated is extremely helpful), universally using type aliases like that pretty much entirely prevents the class of bugs from accidentally passing a string/int typed value into a variable of the wrong stringy/inty type, e.g. mixing up different categories of id or name or whatever.

There are no comments on this comment yet.