Effect CommunityEC
Effect Community2y ago
43 replies
jessekelly

Proposal: Adding Schema.sandbox to Handle Invalid Types Gracefully

Would a Schema.sandbox be something worth adding to the core lib? I.e. a helper that interprets an invalid type of a schema as a none.

const s = Schema.Struct({
  a: Schema.sandbox(Schema.Number),
  b: Schema.sandbox(Schema.String),
  c: Schema.String
})

// { a: Option.None, b: Option.some("b"), c: "c" }
Schema.decode(s)({
  a: "a",
  b: "b",
  c: "c"
})
Was this page helpful?