Effect CommunityEC
Effect Community3y ago
27 replies
Kristian Notari

Schema Decoding Behavior: Excess Properties in Output

I remember some weeks ago reading somewhere that Schema decoding was always stripping excess properties and the only configurable behaviour was whether error on those or just silently ignore them. Right now with version 0.34.0 I get those excess properties as the output of decoding with a Schema.struct({}) with no properties.

Example:
const s1 = Schema.struct({ a: Schema.string })
Schema.decodeSync(s1)({ a: 'hello'}) // { a: 'hello' } ✅
Schema.decodeSync(s1)({ a: 'hello', b: 'excess' }) // { a: 'hello' } ✅

const s2 = Schema.struct({ })
Schema.decodeSync(s2)({ a: 'excess' }) // { a: 'excess' } ❌
Was this page helpful?