SlideShare a Scribd company logo
Casting and Validating State With
Archetype
Valeri Karpov
Booster Fuels
@code_barbarian
github.com/vkarpov15
About Me
React Credentials
What is Archetype?
Cast a given obj’s properties to the correct types
So It’s Joi, JSONSchema, PropTypes, Flow?
● Easy custom types & nested (vs Joi, JSONSchema)
● Casting + validation in middleware vs PropTypes
● Runtime, not compile time vs Flow (buggy APIs)
Core Principles
● Composable: can nest and transform types
● Inspectable: introspect deeply nested paths
● Extendable: any class is a valid custom type
Data for Calendar App in React
Rendering comes with Assumptions
And With Bad Data?
Use Archetype to Consolidate Logic
Using Action Creators
Know Your Assumptions are Correct
And No More Walls of If Statements
More Info on Archetype
● Gists of the week available on
npmjs.com/package/archetype
● Casting and Validating GeoJSON With Archetype
on thecodebarbarian.com
Thanks!
Code samples: /vkarpov15/zcal-client-example

More Related Content

PDF
Backend to frontend
PDF
ReactiveX
PDF
ReactiveX-SEA
PDF
Devoxx France 2018 GraphQL vs Traditional REST API
PDF
Java Day Istanbul 2018 GraphQL vs Traditional REST API
ODP
Auth of restful_api
ODP
Elixir absinthe-basics
PDF
A Practical Introduction to GeoJSON
Backend to frontend
ReactiveX
ReactiveX-SEA
Devoxx France 2018 GraphQL vs Traditional REST API
Java Day Istanbul 2018 GraphQL vs Traditional REST API
Auth of restful_api
Elixir absinthe-basics
A Practical Introduction to GeoJSON

More from Valeri Karpov (20)

PDF
A Practical Introduction to Functions-as-a-Service
PDF
A Gentle Introduction to Functions-as-a-Service
PDF
Introducing Async/Await
PDF
TAO and the Essence of Modern JavaScript
PDF
Mastering Async/Await in JavaScript
PDF
TDD a REST API With Node.js and MongoDB
PDF
Conquering AngularJS Limitations
PDF
MongoDB MEAN Stack Webinar October 7, 2015
PDF
MEAN Stack NYC Meetup 20150717: TDD Your AngularJS + Ionic Directives With jQ...
PDF
Lessons in Open Source from the MongooseJS ODM
PDF
Nimrod: MongoDB Shell in NodeJS (JSConfUY 2015)
PDF
MongoDB Miami Meetup 1/26/15: Introduction to WiredTiger
PDF
MongoDB API Talk @ HackPrinceton
PDF
MEAN Stack WeNode Barcelona Workshop
PDF
MongoDB Israel June Meetup
PDF
JS-IL: Getting MEAN in 1 Hour
PDF
JS-IL Keynote: MongoDB 2.6, Mongoose 4.0, and Beyond
PDF
MEAN Stack Workshop at Node Philly, 4/9/14
PDF
MongoDB: Queries and Aggregation Framework with NBA Game Data
PDF
Mongo db in 3 minutes BoilerMake
A Practical Introduction to Functions-as-a-Service
A Gentle Introduction to Functions-as-a-Service
Introducing Async/Await
TAO and the Essence of Modern JavaScript
Mastering Async/Await in JavaScript
TDD a REST API With Node.js and MongoDB
Conquering AngularJS Limitations
MongoDB MEAN Stack Webinar October 7, 2015
MEAN Stack NYC Meetup 20150717: TDD Your AngularJS + Ionic Directives With jQ...
Lessons in Open Source from the MongooseJS ODM
Nimrod: MongoDB Shell in NodeJS (JSConfUY 2015)
MongoDB Miami Meetup 1/26/15: Introduction to WiredTiger
MongoDB API Talk @ HackPrinceton
MEAN Stack WeNode Barcelona Workshop
MongoDB Israel June Meetup
JS-IL: Getting MEAN in 1 Hour
JS-IL Keynote: MongoDB 2.6, Mongoose 4.0, and Beyond
MEAN Stack Workshop at Node Philly, 4/9/14
MongoDB: Queries and Aggregation Framework with NBA Game Data
Mongo db in 3 minutes BoilerMake
Ad

Recently uploaded (20)

PDF
cuic standard and advanced reporting.pdf
PPT
“AI and Expert System Decision Support & Business Intelligence Systems”
PPTX
Cloud computing and distributed systems.
PDF
7 ChatGPT Prompts to Help You Define Your Ideal Customer Profile.pdf
PDF
Per capita expenditure prediction using model stacking based on satellite ima...
PPTX
KOM of Painting work and Equipment Insulation REV00 update 25-dec.pptx
PDF
Electronic commerce courselecture one. Pdf
PDF
Advanced methodologies resolving dimensionality complications for autism neur...
PPTX
Programs and apps: productivity, graphics, security and other tools
PDF
Unlocking AI with Model Context Protocol (MCP)
PDF
TokAI - TikTok AI Agent : The First AI Application That Analyzes 10,000+ Vira...
PDF
The Rise and Fall of 3GPP – Time for a Sabbatical?
PDF
Empathic Computing: Creating Shared Understanding
PPTX
Understanding_Digital_Forensics_Presentation.pptx
PDF
Mobile App Security Testing_ A Comprehensive Guide.pdf
PDF
MIND Revenue Release Quarter 2 2025 Press Release
PDF
Diabetes mellitus diagnosis method based random forest with bat algorithm
PDF
Review of recent advances in non-invasive hemoglobin estimation
PDF
Machine learning based COVID-19 study performance prediction
PDF
Building Integrated photovoltaic BIPV_UPV.pdf
cuic standard and advanced reporting.pdf
“AI and Expert System Decision Support & Business Intelligence Systems”
Cloud computing and distributed systems.
7 ChatGPT Prompts to Help You Define Your Ideal Customer Profile.pdf
Per capita expenditure prediction using model stacking based on satellite ima...
KOM of Painting work and Equipment Insulation REV00 update 25-dec.pptx
Electronic commerce courselecture one. Pdf
Advanced methodologies resolving dimensionality complications for autism neur...
Programs and apps: productivity, graphics, security and other tools
Unlocking AI with Model Context Protocol (MCP)
TokAI - TikTok AI Agent : The First AI Application That Analyzes 10,000+ Vira...
The Rise and Fall of 3GPP – Time for a Sabbatical?
Empathic Computing: Creating Shared Understanding
Understanding_Digital_Forensics_Presentation.pptx
Mobile App Security Testing_ A Comprehensive Guide.pdf
MIND Revenue Release Quarter 2 2025 Press Release
Diabetes mellitus diagnosis method based random forest with bat algorithm
Review of recent advances in non-invasive hemoglobin estimation
Machine learning based COVID-19 study performance prediction
Building Integrated photovoltaic BIPV_UPV.pdf
Ad

React, Redux, and Archetype