Skip to content

Combination of S.nullable and prop.opt #37

@schickling

Description

@schickling

Is your feature request related to a problem? Please describe.

When when modelling an object using S.props it's currently possible to make a field "nullable or optional" using

  1. myProp: S.prop(S.nullable(S.string))
  2. myProp: S.prop(S.string).opt()

(1) results in accepting null or "some-str" as value and being parsed into myProp: O.Option<string>.
(2) results in accepting undefined, "some-str" or omitting the field and being parsed into byProp: string | undefined.

Describe the solution you'd like

I'd like something "in between". Basically something that allows me to omit a field like in (2) but being parsed into an option like in (1)

Describe alternatives you've considered

Additional context

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions