Quantcast
Channel: ReScript Forum - Latest posts
Viewing all articles
Browse latest Browse all 2592

Model string value from external system

$
0
0

Hello,

I would like to model the a record field contactPerson of type string.
It can be absent from the record, so one would think to use option<string>, however, if the value is absent it will be undefined which is problematic to store in my external system.

type Info = {
  contactPerson: option<string> // actual string or undefined
}

So, I need to model it that is would either be an actual non empty string value or null.

// in js
let a = { contactPerson: "Foo" }
let b = { contactPerson: null }
// invalid! for my use case
let c = { contactPerson: undefined }

How would I do this in ReScript?


Viewing all articles
Browse latest Browse all 2592

Trending Articles