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
Reactとフォームとスキーマバリデーション / React forms with Schem...
Search
kamijin_fanta
January 12, 2021
Technology
2.7k
0
Share
Reactとフォームとスキーマバリデーション / React forms with Schema Validation
kamijin_fanta
January 12, 2021
More Decks by kamijin_fanta
See All by kamijin_fanta
2025-09-22 Iceberg, Trinoでのログ基盤構築と パフォーマンス最適化
kamijin_fanta
1
810
2025-04-14 Data & Analytics 井戸端会議 Multi tenant log platform with Iceberg
kamijin_fanta
1
680
IoT向けストレージにTiKVを採用したときの話 / 2024-10-25 TiUG Meetup 3 Using TiKV as IoT storage
kamijin_fanta
0
170
TrinoとIcebergで ログ基盤の構築 / 2023-10-05 Trino Presto Meetup
kamijin_fanta
1
2.4k
Unicodeと符号化形式
kamijin_fanta
0
1.2k
2020/05/25 さくらのクラウド向けツールを使いこなす
kamijin_fanta
3
370
2019-01-24 業務でのOSSとの関わり方
kamijin_fanta
7
5k
関数型言語で始めるネットワークプログラミング
kamijin_fanta
0
1.2k
2018-11-10 Akka-HTTPで作るAPIサーバ
kamijin_fanta
2
4.1k
Other Decks in Technology
See All in Technology
データ定義の混乱と戦う 〜 管理会計と財務会計 〜
wonohe
0
150
Cortex Codeのコスト見積ヒントご紹介
yokatsuki
0
120
巨大プラットフォームを進化させる「第3のROI」
recruitengineers
PRO
2
1.3k
[最強DB講義]推薦システム | 評価編
recsyslab
PRO
0
110
音声言語モデル手法に関する発表の紹介
kzinmr
0
140
AWS DevOps Agentはチームメイトになれるのか?/ Can AWS DevOps Agent become a teammate
kinunori
6
780
Good Enough Types: Heuristic Type Inference for Ruby
riseshia
1
320
はじめての MagicPod生成AI機能 機能紹介から活用方法まで
magicpod
0
120
Keeping Ruby Running on Cygwin
fd0
0
180
AI: Making Admin and Users, Lives Better
kbmsg
0
120
基盤を育てる 外部SaaS連携の運用
gamonges_dresscode
1
120
ハーネスエンジニアリングをやりすぎた話 ~そのハーネスは解体された~
gotalab555
5
1.9k
Featured
See All Featured
Practical Tips for Bootstrapping Information Extraction Pipelines
honnibal
25
1.9k
Design in an AI World
tapps
1
200
Primal Persuasion: How to Engage the Brain for Learning That Lasts
tmiket
0
330
XXLCSS - How to scale CSS and keep your sanity
sugarenia
250
1.3M
Kristin Tynski - Automating Marketing Tasks With AI
techseoconnect
PRO
0
230
The SEO identity crisis: Don't let AI make you average
varn
0
450
How Fast Is Fast Enough? [PerfNow 2025]
tammyeverts
3
540
Groundhog Day: Seeking Process in Gaming for Health
codingconduct
0
150
Rebuilding a faster, lazier Slack
samanthasiow
85
9.5k
Mind Mapping
helmedeiros
PRO
1
160
Testing 201, or: Great Expectations
jmmastey
46
8.1k
Why Mistakes Are the Best Teachers: Turning Failure into a Pathway for Growth
auna
0
120
Transcript
React forms with Schema Validation 2021/01/12 kamijin-fanta
TypeScriptやってますか データ構造のValidationやってますか
Data Structure Validation フィールド型・データの範囲などを定義・検証する仕組み ⼈間が検証コードを書く必要が無くなって良い spec JSON Schema Swagger impl:
go, python等様々な⾔語にてライブラリが存在 { "type": "string", "minLength": 2, "maxLength": 3 }
superstruct TypeScriptで利⽤できるデータ検証ライブラリ https://docs.superstructjs.org/ サンプルコード: https://github.com/kamijin-fanta/react-form-schemavalidation- example/blob/master/src/superstruct/basic.test.ts
superstructの使いみち APIで投げられたPOST Bodyの検証 ユーザの⼊⼒フォームの検証 ← 便利そう
react-hook-form パフォーマンスが良いReactのフォームライブラリ バリデーション・繰り返しフィールド等の機能が⼀通り揃っていて良い サンプルコード: https://github.com/kamijin-fanta/react-form-schemavalidation- example/blob/master/src/simple-form/simple-form.tsx
react-hook-formの⾯倒な所 エラー⽂章を⾃分で書く必要が有る バリデーション内容から勝⼿に⽂章作って欲しい errors onSubmit が型安全でない
react-hook-form+superstruct react-hook-form で書いていたルールを全てsuperstructで定義する superstructがエラー⽂の⽣成する superstructが型を定義する react-hook-formの⾟さを軽減出来る https://github.com/kamijin-fanta/react-form-schemavalidation- example/blob/master/src/schema-validation-form/schema-validation-form.tsx
react-hook-form+superstruct構成はreactでフォーム作る⼈にオススメ