<?xml version="1.0" encoding="utf-8" standalone="yes"?><rss version="2.0" xmlns:atom="http://www.w3.org/2005/Atom"><channel><title>Parsing on cekrem.github.io</title><link>https://cekrem.github.io/tags/parsing/</link><description>Recent content in Parsing on cekrem.github.io</description><generator>Hugo</generator><language>en-us</language><lastBuildDate>Tue, 07 Apr 2026 00:00:00 +0000</lastBuildDate><atom:link href="https://cekrem.github.io/tags/parsing/index.xml" rel="self" type="application/rss+xml"/><item><title>Parse, Don't Validate — In a Language That Doesn't Want You To</title><link>https://cekrem.github.io/posts/parse-dont-validate-typescript/</link><pubDate>Tue, 07 Apr 2026 00:00:00 +0000</pubDate><guid>https://cekrem.github.io/posts/parse-dont-validate-typescript/</guid><description>&lt;p&gt;I&amp;rsquo;ve been thinking about Alexis King&amp;rsquo;s &lt;a href="https://lexi-lambda.github.io/blogs/2019-11-05-parse-don-t-validate/" class="external-link" target="_blank" rel="noopener"&gt;Parse, don&amp;rsquo;t validate&lt;/a&gt; again. I do this quite regularly, actually, usually after staring at a TypeScript codebase that&amp;rsquo;s been quietly accumulating &lt;code&gt;if (user.email)&lt;/code&gt; checks like barnacles. The post is from 2019, and the advice (or rather principle) is way older than that. And yet most TypeScript I read — including, embarrassingly, plenty I&amp;rsquo;ve written — still validates instead of parsing.&lt;/p&gt;
&lt;p&gt;The pitch, if you haven&amp;rsquo;t read it (you should): a validator says &amp;ldquo;this thing is fine, please continue.&amp;rdquo; A parser says &amp;ldquo;give me a blob, and I&amp;rsquo;ll either give you back a more precise type or tell you why I can&amp;rsquo;t.&amp;rdquo; The difference sounds academic until you realize that validators throw away information the moment they finish running, while parsers &lt;em&gt;preserve&lt;/em&gt; what they learned by encoding it in the type. Once you&amp;rsquo;ve parsed a string into an &lt;code&gt;EmailAddress&lt;/code&gt;, the rest of your program never has to wonder again. Peace of mind and more mental capacity for the fun stuff.&lt;/p&gt;</description></item></channel></rss>