Flow Guard
Flow Guard is a babel macro that adds a runtime guard for your flow types. This macro generates decoders based on your flow types and throws a runtime error if the unsafe data does not match. It is useful to type-check the boundaries of your application for incoming unsafe data (See decoders).
Example guard macro
// @flow; type Point = x: number y: number ; : Point { return guard<Point>someUnsafeData;}
Example decoder macro
// @flow;; type Point = x: number y: number ; const pointDecoder = createDecoder<Point>; : Point { return someUnsafeData;}
Installation
Requires babel 7.x
npm install --save-dev babel-plugin-macros
npm install --save-dev flow-guard
Edit .babelrc to include the macros plugin: 'macros'