Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

How do you create a decoder with an fp-ts Option field? #598

Open
fillon opened this issue Jun 29, 2021 · 2 comments
Open

How do you create a decoder with an fp-ts Option field? #598

fillon opened this issue Jun 29, 2021 · 2 comments

Comments

@fillon
Copy link

fillon commented Jun 29, 2021

Hi,

How do you create a decoder with an Option type?

import * as D from 'io-ts/lib/Decoder'
import * as O from 'fp-ts/lib/Option'

const Response = D.array(D.struct({
    ip: D.string,
    countryName: O.Option<string> <-- ??
}))
@DenisFrezzato
Copy link

DenisFrezzato commented Jun 29, 2021

See option or optionFromNullable from io-ts-types. The experimental modules are not supported in io-ts-types yet, but you can replicate the same behaviours. There is also an open PR you can copy from.

@fillon
Copy link
Author

fillon commented Jun 29, 2021

Doesn't seem to work with the new Decoder

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants