Created
September 9, 2019 20:47
-
-
Save dgieselaar/fc5f48b25fa0a6a8d205b07ec4e845b5 to your computer and use it in GitHub Desktop.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
import { pipe } from 'fp-ts/lib/pipeable'; | |
import { fold } from 'fp-ts/lib/Either'; | |
import codec from './codec.ts'; | |
const input = { | |
title: 'Title of this article', | |
content: 'Content of this article', | |
options: { | |
private: true | |
} | |
}; | |
const result = pipe( | |
codec.decode(input), | |
fold( | |
() => { | |
throw new Error('Input validation error'); | |
}, | |
val => val | |
) | |
); | |
/* | |
right = { | |
title: string, | |
content: string, | |
options: { | |
private?: boolean | |
} | |
} | |
*/ | |
const { right } = result; |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment