Upgrade to Pro
— share decks privately, control downloads, hide ads and more …
Speaker Deck
Sign up for free
Menu
Search
Features
All features
Private URLs
Password Protection
Custom URLS
Scheduled publishing
Remove Branding
Restrict embedding
Deck Collections
Notes
Features
All features
Private URLs
Password Protection
Custom URLS
Scheduled publishing
Remove Branding
Restrict embedding
Deck Collections
Notes
Explore
Featured decks
Featured speakers
Programming
Technology
Storyboards
Explore
Featured decks
Featured speakers
Programming
Technology
Storyboards
Pricing
Search
Sign in
Sign up for free
Zodのデータ変換が便利すぎた。 しかし使いすぎで苦しくなっていった話
Search
Melonps
May 09, 2026
Technology
98
0
Share
Embed
Copy iframe code
Copy JS code
Copy link
Start on current slide
Zodのデータ変換が便利すぎた。 しかし使いすぎで苦しくなっていった話
フロントエンドカンファレンス名古屋のLT登壇資料です。
Melonps
May 09, 2026
More Decks by Melonps
See All by Melonps
コーディングエージェントはTypeScriptの 型エラーをどう自己修正しているのか
melonps
4
850
さくらのAI Engineから始める クラウドネイティブ意識
melonps
0
360
15年続くIoTサービスのSREエンジニアが挑む分散トレーシング導入
melonps
2
790
OpenTelemetryで“見えるIoT”を目指したら クラウドネイティブの奥深さに直面した
melonps
0
100
LangChainについてのサーベイ
melonps
0
230
CloudSeed
melonps
0
200
Other Decks in Technology
See All in Technology
JAWS-UGグッズ職人仕事の流儀
kentapapa
0
130
古い指輪から広がった JAVA コミュニティ とのつながり
yamad
0
140
Persisting Massive Data with Rails ~Designing for 60 billion rows, and fighting the bottlenecks~ Railsで挑む大量データ永続化 〜600億件を永続化するための設計とボトルネックとの戦い〜
occhi
0
770
AI駆動開発におけるハーネスエンジニアリングの勘所
tsukuboshi
1
350
JAWSUG TOHOKU 青森支部 「LoGoチャット」のAWS移行で 乗り越えたこと
taketakekaho
0
360
Rustuna: Rustによる高速なOptuna実装
pfn
PRO
0
210
Classmethod Company Deck
satoshi7
1
800
野蛮なアジャイル [サイボウズ発!]組織の常識を覆した反骨のスクラム実践記 / Barbaric Agile - Enterprise Agile Study Group
ama_ch
0
120
スプシの手作業からの解脱 ~更新はClaude Codeに、見せ方と使い方はGASアプリに任せる~
kentarofujii
0
170
コンテナ運用におけるネットワーク・コンテナコストの削減方法/How to Reduce Network and Container Costs in Container Operations
masakiokuda
2
370
10年後、Engineering 行為を剥奪されるとして、わたしたちは、どう、何を創ればいいだろうか。 / If Engineering Is Taken Away in 10 Years, How and What Should We Create?
bitkey
PRO
1
220
Refining Active Record
shugo
0
190
Featured
See All Featured
How Software Deployment tools have changed in the past 20 years
geshan
2
35k
A Soul's Torment
seathinner
8
3.8k
Dominate Local Search Results - an insider guide to GBP, reviews, and Local SEO
greggifford
PRO
0
370
Agile Actions for Facilitating Distributed Teams - ADO2019
mkilby
0
310
Ethics towards AI in product and experience design
skipperchong
2
440
Understanding Cognitive Biases in Performance Measurement
bluesmoon
32
3.1k
Helping Users Find Their Own Way: Creating Modern Search Experiences
danielanewman
31
3.4k
技術選定の審美眼(2025年版) / Understanding the Spiral of Technologies 2025 edition
twada
PRO
120
120k
Balancing Empowerment & Direction
lara
6
1.3k
SERP Conf. Vienna - Web Accessibility: Optimizing for Inclusivity and SEO
sarafernandez
2
1.6k
Chrome DevTools: State of the Union 2024 - Debugging React & Beyond
addyosmani
10
1.4k
職位にかかわらず全員がリーダーシップを発揮するチーム作り / Building a team where everyone can demonstrate leadership regardless of position
madoxten
69
67k
Transcript
Zodのデータ変換が便利すぎた。 しかし使いすぎで苦しくなっていった話 パナソニック エレクトリックワークス株式会社 筧 万里 1 フロントエンドカンファレンス名古屋 2026 LT
自己紹介 2 BANRI KAKEHI(@Melonps_) ◦ 家庭用燃料電池「エネファーム」のSRE ◦ クラウドネイティブ会議実行委員 ◦ Yamada
UIのメンテナー エネファーム
スキーマ定義にどこまで書くか? ◎Zodで型定義とバリデーションと両立させて使う形が多い 3 const UserSchema = z.object({ name: z.string(), age:
z.number().min(0), email: z.email(), }); const result = UserSchema.safeParse({ name: "太郎", age: 1000, email: "
[email protected]
", }); console.log(result.success, result.data) スキーマ定義(TS) パースによるランタイムでの検証 APIレスポンスの検証やフォーム入力制御で活躍
データ変換ツールとしても進化してきた .transform():バリデーション後に型変換 4 const NameLengthSchema = z.string().transform((val) => val.length); type
Input = z.input<typeof NameLengthSchema>; type Output = z.output<typeof NameLengthSchema>; .pipe():変換後の値に再バリデーション const SafeStringToNumber = z.string() .transform((value) => Number(value)) .pipe(z.number().min(0).max(100)); numberが確定 0~100が確定
何でこれが苦しくなるの? 5 データ変換を使い倒して 便利だった実装と苦しくなっていった実装
便利だった 便利だった実装:APIレスポンスの入り口 6 const EventSchema = z.object({ startAt: z.iso.datetime().transform((val) =>
new Date(val)), endAt: z.iso.datetime().transform((val) => new Date(val)), }).refine((data) => data.endAt.getTime() > data.startAt.getTime(), { message: "終了時刻は開始時刻より後に設定してください", path: ["endAt"], }); ◎APIから得たデータの論理と型の検証をする 論理の保証 ルールの整備がないままtransform化が進んでいった Date型へ変換
苦しくなった const EventSchema = z.object({ startAt: z.iso.datetime().transform((val) => new Date(val)),
endAt: z.iso.datetime().transform((val) => new Date(val)), attendees: z.array(z.object({ name: z.string(), role: z.string() })), }).transform((event) => ({ ...event, duration: event.endAt.getTime() - event.startAt.getTime(), activeAttendees: event.attendees.filter((a) => a.role !== "observer"), })); 苦しくなっていった実装 7 ◎データクレンジングや表示用の変換を持ち始めた →スキーマを追加するごとに、テストや議論が必要な状態に... 表示用の変換 useFormに渡す型はIn?Out? フィルタリング
どうすれば良かったのか? 8 ビジネスロジック ◎外部の不確実性から守るため、スキーマを境界の入り口とするべき ◦ 複数の境界をまたぐ変換は不適切 ◦ 同じ境界の中であれば、関数に切り出すべき Functional Core
Mutable Shell
こう整理して挑戦中です 9 ◎スキーマを定義する前のチェックリスト リファクタ案やブランド型の話もしたかった... ◦ ①:「何と何の境界」を担っているか説明できるか? ◦ ②:外→内への境界か、内→内への境界か?(後者なら関数に切り出す) ◦ ③:一つだけの境界を対象としているか?
ご清聴ありがとうございました!
None