<?xml version="1.0" encoding="UTF-8"?>
<rss version="2.0" xmlns:atom="http://www.w3.org/2005/Atom" xmlns:dc="http://purl.org/dc/elements/1.1/">
  <channel>
    <title>DEV Community: Roy Tang</title>
    <description>The latest articles on DEV Community by Roy Tang (@roy_tang_ef275a1be2fc5afb).</description>
    <link>https://dev.to/roy_tang_ef275a1be2fc5afb</link>
    <image>
      <url>https://media2.dev.to/dynamic/image/width=90,height=90,fit=cover,gravity=auto,format=auto/https:%2F%2Fdev-to-uploads.s3.us-east-2.amazonaws.com%2Fuploads%2Fuser%2Fprofile_image%2F4040086%2Fdf8f3b92-4679-4555-82e0-3cd8c57184ac.png</url>
      <title>DEV Community: Roy Tang</title>
      <link>https://dev.to/roy_tang_ef275a1be2fc5afb</link>
    </image>
    <atom:link rel="self" type="application/rss+xml" href="https://dev.to/feed/roy_tang_ef275a1be2fc5afb"/>
    <language>en</language>
    <item>
      <title>Why your fake US test addresses fail validation (and how to fix it)</title>
      <dc:creator>Roy Tang</dc:creator>
      <pubDate>Tue, 21 Jul 2026 12:15:59 +0000</pubDate>
      <link>https://dev.to/roy_tang_ef275a1be2fc5afb/why-your-fake-us-test-addresses-fail-validation-and-how-to-fix-it-2kii</link>
      <guid>https://dev.to/roy_tang_ef275a1be2fc5afb/why-your-fake-us-test-addresses-fail-validation-and-how-to-fix-it-2kii</guid>
      <description>&lt;p&gt;If you've ever seeded a staging database with &lt;code&gt;faker&lt;/code&gt; and then watched&lt;br&gt;
your checkout form reject every single address, this post is for you.&lt;/p&gt;

&lt;h2&gt;
  
  
  The problem: three layers of address validation
&lt;/h2&gt;

&lt;p&gt;Address fields in a modern US checkout or signup form typically pass&lt;br&gt;
through three layers:&lt;/p&gt;

&lt;ol&gt;
&lt;li&gt;
&lt;strong&gt;Format checks&lt;/strong&gt; — is the ZIP five digits, is the state a valid
two-letter code? Any random data passes this.&lt;/li&gt;
&lt;li&gt;
&lt;strong&gt;Region-consistency checks&lt;/strong&gt; — do the city, state and ZIP actually
belong together? USPS-style validators and services like Google
Address Validation all do this. &lt;code&gt;123 Main St, New York, CA 90001&lt;/code&gt;
dies here: New York is not in California, and 90001 is Los Angeles.&lt;/li&gt;
&lt;li&gt;
&lt;strong&gt;Deliverability checks&lt;/strong&gt; — does the house number exist? Only
logistics flows go this deep; test environments almost never need it.&lt;/li&gt;
&lt;/ol&gt;

&lt;p&gt;The catch: most fake-data libraries generate each field&lt;br&gt;
&lt;strong&gt;independently&lt;/strong&gt;. &lt;code&gt;faker.location.city()&lt;/code&gt; and&lt;br&gt;
&lt;code&gt;faker.location.zipCode()&lt;/code&gt; don't know about each other, so nearly every&lt;br&gt;
generated record fails layer 2 — and your tests fail for reasons that&lt;br&gt;
have nothing to do with your code.&lt;/p&gt;

&lt;h2&gt;
  
  
  Fix 1: hand-curated matched sets
&lt;/h2&gt;

&lt;p&gt;For a handful of records, just keep a small table of combinations that&lt;br&gt;
belong together:&lt;/p&gt;

&lt;div class="table-wrapper-paragraph"&gt;&lt;table&gt;
&lt;thead&gt;
&lt;tr&gt;
&lt;th&gt;City&lt;/th&gt;
&lt;th&gt;State&lt;/th&gt;
&lt;th&gt;ZIP&lt;/th&gt;
&lt;th&gt;Area code&lt;/th&gt;
&lt;/tr&gt;
&lt;/thead&gt;
&lt;tbody&gt;
&lt;tr&gt;
&lt;td&gt;Portland&lt;/td&gt;
&lt;td&gt;OR&lt;/td&gt;
&lt;td&gt;97205&lt;/td&gt;
&lt;td&gt;503&lt;/td&gt;
&lt;/tr&gt;
&lt;tr&gt;
&lt;td&gt;Austin&lt;/td&gt;
&lt;td&gt;TX&lt;/td&gt;
&lt;td&gt;78701&lt;/td&gt;
&lt;td&gt;512&lt;/td&gt;
&lt;/tr&gt;
&lt;tr&gt;
&lt;td&gt;Denver&lt;/td&gt;
&lt;td&gt;CO&lt;/td&gt;
&lt;td&gt;80202&lt;/td&gt;
&lt;td&gt;303&lt;/td&gt;
&lt;/tr&gt;
&lt;/tbody&gt;
&lt;/table&gt;&lt;/div&gt;

&lt;p&gt;Worth adding to any test suite as edge cases:&lt;/p&gt;

&lt;ul&gt;
&lt;li&gt;
&lt;strong&gt;Two-word states&lt;/strong&gt; — &lt;code&gt;Rhode Island&lt;/code&gt;, &lt;code&gt;South Carolina&lt;/code&gt;: naive parsers
split on spaces and read &lt;code&gt;Rhode&lt;/code&gt; as a city.&lt;/li&gt;
&lt;li&gt;
&lt;strong&gt;Washington, DC&lt;/strong&gt; — not a state, but every form treats it as one.
Its addresses carry quadrant suffixes (&lt;code&gt;1600 K St NW&lt;/code&gt; ≠ &lt;code&gt;1600 K St NE&lt;/code&gt;).&lt;/li&gt;
&lt;li&gt;
&lt;strong&gt;Utah grid addresses&lt;/strong&gt; — &lt;code&gt;455 S 300 E&lt;/code&gt; has no street &lt;em&gt;name&lt;/em&gt; at all.
Great for breaking address parsers that assume &lt;code&gt;Name + St/Ave&lt;/code&gt;.&lt;/li&gt;
&lt;li&gt;
&lt;strong&gt;Tax-free states&lt;/strong&gt; — OR, DE, MT, NH, AK have no statewide sales tax;
pair them with a high-tax state like CA to test both checkout branches.&lt;/li&gt;
&lt;/ul&gt;

&lt;h2&gt;
  
  
  Fix 2: a dataset with the relationships baked in
&lt;/h2&gt;

&lt;p&gt;I open-sourced the states/cities/ZIP building blocks I use (MIT):&lt;br&gt;
&lt;a href="https://github.com/tuansuwu/us-address-sample-data" rel="noopener noreferrer"&gt;us-address-sample-data&lt;/a&gt;&lt;br&gt;
— 51 states with real area codes and tax flags, 255 cities where every&lt;br&gt;
ZIP genuinely belongs to that city. Import the JSON and compose&lt;br&gt;
addresses locally with zero dependencies.&lt;/p&gt;

&lt;h2&gt;
  
  
  Fix 3: an API that does it for you
&lt;/h2&gt;

&lt;p&gt;For CI or quick scripts, I built a free endpoint (no key, CORS enabled,&lt;br&gt;
up to 100 records per request):&lt;/p&gt;



&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;
bash
curl "https://addressmock.com/api/addresses?count=10&amp;amp;state=CA"
Copy
const res = await fetch(
  "https://addressmock.com/api/addresses?count=20&amp;amp;type=us_tax_free"
);
const { results } = await res.json();
// every record: matched city/state/ZIP/area code + name, email, phone
Copy
Parameters: count (1–100), type (us / us_tax_free / hk / cv), state, city, gender. There's also a browser UI with batch generation and CSV/JSON export if you prefer clicking to curling.

The obligatory disclaimer

All of this produces format-correct samples, not verified deliverable addresses. It's for testing, demos and seeding — using fake addresses for real shipping, KYC or dodging region checks is a different thing entirely, and platforms are good at catching it.

What other locales or formats would be useful? I'm considering UK postcodes and Canadian postal codes next.
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;

</description>
      <category>testing</category>
      <category>webdev</category>
      <category>api</category>
      <category>tutorial</category>
    </item>
  </channel>
</rss>
