Upgrade to Pro
— share decks privately, control downloads, hide ads and more …
Speaker Deck
Features
Speaker Deck
PRO
Sign in
Sign up for free
Search
Search
Zodのデータ変換が便利すぎた。 しかし使いすぎで苦しくなっていった話
Search
Melonps
May 09, 2026
Technology
69
0
Share
Zodのデータ変換が便利すぎた。 しかし使いすぎで苦しくなっていった話
フロントエンドカンファレンス名古屋のLT登壇資料です。
Melonps
May 09, 2026
More Decks by Melonps
See All by Melonps
コーディングエージェントはTypeScriptの 型エラーをどう自己修正しているのか
melonps
4
570
さくらのAI Engineから始める クラウドネイティブ意識
melonps
0
230
15年続くIoTサービスのSREエンジニアが挑む分散トレーシング導入
melonps
2
630
OpenTelemetryで“見えるIoT”を目指したら クラウドネイティブの奥深さに直面した
melonps
0
54
LangChainについてのサーベイ
melonps
0
210
CloudSeed
melonps
0
170
Other Decks in Technology
See All in Technology
Javaコミュニティをもっと楽しむための9箇条
takasyou
0
830
大学生が本気でDatabricksを活用してDiscordサークルをデータ駆動させてみた
phantomjuju
1
310
もりもり新機能を一挙紹介! AgentCoreに入門して、AWS上にAIエージェントを構築しよう
minorun365
PRO
6
510
自称宇宙最速で不合格となったAIP-C01にリベンジを果たすべくAIで問題集アプリを作ってみた。
yama3133
0
260
オンコールの負荷軽減のためのBits Assistant 活用方法 / How to Use Bits Assistant to Reduce the Workload on On-Call Staff
sms_tech
1
360
Terraformモジュールは、なぜ「魔境」化するのか
hayama17
1
130
OpenClawとHermesAgentでAI新入社員を作った話
takanoriyanada
0
150
エンジニアは生成AIと どのように向き合うべきか? ことばの意味という観点から
verypluming
3
310
Sony_KMP_Journey_KotlinConf2026
sony
1
190
AI-DLCを活用した高品質・安全なAI駆動開発実践 / AI Driven Development
yoshidashingo
1
280
はじめてのDatadog
kairim0
0
240
Dynamic Workersについて
yusukebe
2
540
Featured
See All Featured
Building Adaptive Systems
keathley
44
3k
Scaling GitHub
holman
464
140k
Applied NLP in the Age of Generative AI
inesmontani
PRO
4
2.3k
WCS-LA-2024
lcolladotor
0
610
Leveraging LLMs for student feedback in introductory data science courses - posit::conf(2025)
minecr
1
270
sira's awesome portfolio website redesign presentation
elsirapls
0
270
Leadership Guide Workshop - DevTernity 2021
reverentgeek
1
290
Amusing Abliteration
ianozsvald
1
190
What Being in a Rock Band Can Teach Us About Real World SEO
427marketing
0
240
How to Grow Your eCommerce with AI & Automation
katarinadahlin
PRO
1
190
Principles of Awesome APIs and How to Build Them.
keavy
128
17k
Design and Strategy: How to Deal with People Who Don’t "Get" Design
morganepeng
133
19k
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