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
840
さくらの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
ウォンテッドリーの最近のプロダクトと技術の紹介
stomk
0
310
Gemini Intelligence 入門 ― AppFunctions と Gemini Nano
takuroabe
0
340
Running Kotlin + Quarkus with Lambda
nealle
1
4.1k
AIネイティブ企業への変革。パーソルキャリアが挑む「データメッシュ×ガバナンス」のアーキテクチャ戦略
techtekt
PRO
0
110
局所最適は悪ではない。壊れているのは指標です。量と質を同時に見る先行指標の設計
recruitengineers
PRO
2
200
1つのリクエストを追って理解する - llm-dのP/D分離
akhino
1
180
sue445's proposals 2026
sue445
0
120
Benchmarking Disaggregated Serving on vLLM + Dynamo with a Real Coding-Agent Workload
nttcom
1
210
OptunaHub: ブラックボックス最適化のためのプラットフォーム
pfn
PRO
0
150
野蛮なアジャイル [サイボウズ発!]組織の常識を覆した反骨のスクラム実践記 / Barbaric Agile - Enterprise Agile Study Group
ama_ch
0
120
JAWSUG TOHOKU 青森支部 「LoGoチャット」のAWS移行で 乗り越えたこと
taketakekaho
0
360
夫婦で子育てするための育児標準化
codmoninc
PRO
0
550
Featured
See All Featured
Rebuilding a faster, lazier Slack
samanthasiow
85
9.7k
Design and Strategy: How to Deal with People Who Don’t "Get" Design
morganepeng
133
20k
Leading Effective Engineering Teams in the AI Era
addyosmani
9
2.8k
How To Speak Unicorn (iThemes Webinar)
marktimemedia
1
610
A Tale of Four Properties
chriscoyier
163
24k
StorybookのUI Testing Handbookを読んだ
zakiyama
31
7k
Faster Mobile Websites
deanohume
310
32k
It's Worth the Effort
3n
188
29k
Save Time (by Creating Custom Rails Generators)
garrettdimon
PRO
33
5.3k
Making Projects Easy
brettharned
120
6.8k
Navigating Weather and Climate Data
rabernat
0
560
WENDY [Excerpt]
tessaabrams
14
40k
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