Unexpected Fields Allowed in Decoded Object with Optional Schema Fields

Hey, I've noticed that making any of struct fields optionals like so:
const TestSchema = Schema.partial(
  Schema.Struct({
    id: Schema.String,
  }),
);

or
const TestSchema = Schema.Struct({
  id: Schema.optional(Schema.String),
});


Allows for unknown random fields to be defined in decoded object. Does anybody know if it's correct behaviour or how to avoid that?
I mean I expected such object to fail the decoding:
const testObj = {
  unknownField: 'randomValue'
}
Was this page helpful?