react, redux, and archetype
TRANSCRIPT
Casting and Validating State With Archetype
Valeri KarpovBooster 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 LogicUsing 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