I'm using io-ts to do input validation for an API. I need to ensure there has no un-declared property in the requirement object.
For example, if I define the interface of request as following:
const Request = t.type({
id: t.string,
name: t.string
});
And if the input is as following:
const req = {
id: 'r1',
name: 'req 1',
description: 'desc' // property "description" is not declaration on Request type.
}
and then I do validating as following:
const r = Request.decode(req);
if (isLeft(r)) {
console.log(PathReporter.report(r));
} else {
console.log("validate success");
}
I expect output is an error for the un-declared property. but it is successed.
Have there any way to do the strict validation based on io-ts?
I found a workaround for this question.
https://github.com/gcanti/io-ts/issues/322#issuecomment-513170377