Skip to content

Instantly share code, notes, and snippets.

@JozefFlakus
Last active February 27, 2019 20:43
Show Gist options
  • Save JozefFlakus/4121ffe104634c9cc1d8eb9b158f19f3 to your computer and use it in GitHub Desktop.
Save JozefFlakus/4121ffe104634c9cc1d8eb9b158f19f3 to your computer and use it in GitHub Desktop.
const userSchema: t.type({
id: t.string,
name: t.string,
age: t.number,
roles: t.array(t.union([
t.literal('ADMIN'),
t.literal('GUEST'),
])),
});
// ...
const effect$ = r.pipe(
r.matchPath('/'),
r.matchType('POST'),
r.useEffect(req$ => req$.pipe(
use(requestValidator$({ body: userSchema })),
// ..
)));
👇
(typeof req.body) = {
id: string;
name: string;
age: number;
roles: ('ADMIN' | 'GUEST')[];
};
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment