Effect CommunityEC
Effect Communityโ€ข2y agoโ€ข
21 replies
RJ

Decoding Nested Object with Schema Transformation

Let's say I have an object like this:

{
  nested: {
    foo: "bar" // string
  }
}


That I'd like to decode into this:

{
  baz: "bar" // string
}


Is it possible to accomplish this without writing a custom transformation? I was looking from some property signature option, but didn't find anything that seemed like it would work. I was imagining something like:

Schema.Struct({
  baz: Schema.propertySignature(Schema.String).pipe(
    Schema.fromKey("nested", "foo")
  )
})
Was this page helpful?