<!-- mobian-agent-page publisher="dailydev" canonical="https://daily.dev/posts/treat-boundary-data-as-unknown--rue3fw988" -->

---
title: Treat boundary data as unknown. | daily.dev
description: A short guide argues that data crossing a boundary (like an API response) should be treated as unknown rather than trusted via type assertions. It recommends...
canonical: https://daily.dev/posts/treat-boundary-data-as-unknown--rue3fw988
twitter:card: summary_large_image
twitter:site: @dailydotdev
og:type: website
og:site_name: daily.dev
og:title: Treat boundary data as unknown. | daily.dev
og:description: A short guide argues that data crossing a boundary (like an API response) should be treated as unknown rather than trusted via type assertions. It recommends...
og:url: https://daily.dev/posts/treat-boundary-data-as-unknown--rue3fw988
og:image: https://api.daily.dev/og/posts/rue3fW988.png
og:image:alt: Treat boundary data as unknown.
og:image:width: 1200
og:image:height: 630
og:locale: en
---

> ## Documentation Index
> Fetch the complete documentation index at: https://daily.dev/llms.txt
> Use this file to discover all available pages before exploring further.

# Treat boundary data as unknown.

**[nyaomaru](https://daily.dev/sources/graxwfjk0eop4zs3tdzdr)** · [@nyaomaru](https://daily.dev/nyaomaru) · 1 min read · 0 upvotes · 0 comments

## Summary

A short guide argues that data crossing a boundary (like an API response) should be treated as unknown rather than trusted via type assertions. It recommends validating with composable guard functions and using a safeParse-style approach to narrow the type only after runtime verification, avoiding the false safety of TypeScript type assertions.

## Content

Validate it with composable guards, then let `safeParse` narrow the result. A type assertion performs no runtime check.

[https://is-kit.dev/guides/validate-unknown-without-schema-library](https://is-kit.dev/guides/validate-unknown-without-schema-library)

#typescript #opensource #cleancode

## Similar posts on daily.dev

- [How to Defend Your JavaScript App Against Unsafe Data with TypeScript Guard Utilities](https://daily.dev/posts/how-to-defend-your-javascript-app-against-unsafe-data-with-typescript-guard-utilities-cuooqjnij) · freeCodeCamp · 5 upvotes · 1 comments
- [Stop drifting around in the dark when using "any" and "unknown" TypeScript types](https://daily.dev/posts/stop-drifting-around-in-the-dark-when-using-any-and-unknown-typescript-types-89bkfo9pv) · This is Learning · 0 upvotes · 0 comments
- [Parse, Don't Validate — In a Language That Doesn't Want You To](https://daily.dev/posts/parse-don-t-validate-in-a-language-that-doesn-t-want-you-to-zyfa03chk) · Lobsters · 0 upvotes · 0 comments

---

Tags: [#open-source](https://daily.dev/tags/open-source), [#typescript](https://daily.dev/tags/typescript), [#appsec](https://daily.dev/tags/appsec)

[View this post on daily.dev](https://daily.dev/posts/treat-boundary-data-as-unknown--rue3fw988)

```json
{"@context":"https://schema.org","@graph":[{"@type":"Organization","@id":"https://daily.dev/#organization","name":"daily.dev","url":"https://daily.dev","logo":{"@type":"ImageObject","url":"https://daily.dev/apple-touch-icon.png","width":180,"height":180},"sameAs":["https://twitter.com/dailydotdev","https://github.com/dailydotdev","https://www.linkedin.com/company/daily-dev-ltd"]},{"@type":"WebSite","@id":"https://daily.dev/#website","url":"https://daily.dev","name":"daily.dev","publisher":{"@id":"https://daily.dev/#organization"},"potentialAction":{"@type":"SearchAction","target":{"@type":"EntryPoint","urlTemplate":"https://daily.dev/search?q={search_term_string}"},"query-input":"required name=search_term_string"}}]}
{"@context":"https://schema.org","@type":"DiscussionForumPosting","mainEntityOfPage":"https://daily.dev/posts/treat-boundary-data-as-unknown--rue3fw988","headline":"Treat boundary data as unknown.","text":"A short guide argues that data crossing a boundary (like an API response) should be treated as unknown rather than trusted via type assertions. It recommends validating with composable guard functions and using a safeParse-style approach to narrow the type only after runtime verification, avoiding the false safety of TypeScript type assertions.","url":"https://daily.dev/posts/treat-boundary-data-as-unknown--rue3fw988","datePublished":"2026-09-01T14:48:16.460Z","dateModified":"2026-09-01T14:48:34.592Z","author":{"@type":"Person","name":"nyaomaru","url":"https://daily.dev/nyaomaru","image":"https://avatars.githubusercontent.com/u/90489696?v=4","interactionStatistic":{"@type":"InteractionCounter","interactionType":{"@type":"EndorseAction"},"userInteractionCount":160}},"interactionStatistic":[{"@type":"InteractionCounter","interactionType":{"@type":"LikeAction"},"userInteractionCount":0},{"@type":"InteractionCounter","interactionType":{"@type":"CommentAction"},"userInteractionCount":0}],"isPartOf":{"@type":"WebPage","url":"https://daily.dev/sources/graxwfjk0eop4zs3tdzdr","name":"nyaomaru"}}
{"@context":"https://schema.org","@type":"BreadcrumbList","itemListElement":[{"@type":"ListItem","position":1,"name":"Home","item":"https://daily.dev"},{"@type":"ListItem","position":2,"name":"nyaomaru","item":"https://daily.dev/sources/graxwfjk0eop4zs3tdzdr"},{"@type":"ListItem","position":3,"name":"Treat boundary data as unknown."}]}
```

