Strict validation results in false negative for (A | B) & C type
mdesousa opened this issue · 2 comments
mdesousa commented
Noticed this with the 0.2.0 release.
Consider type AorBandC as defined below:
interface A {
a: string;
}
interface B {
b: string;
}
interface C {
c: string;
}
type AorB = A | B;
type AorBandC = AorB & C;
The following validation results in an unexpected error:
const x: AorBandC = { a: "1", c: "3" };
const error = checkers.AorBandC.strictValidate(x);
expect(error).toBeNull();
The error looks like this:
Received: {"message": "is not a AorB", "nested": [{"message": "is none of A, B", "nested": [{"message": "is not a A", "nested": [{"message": "is extraneous", "path": "value.c"}], "path": "value"}], "path": "value"}], "path": "value"}
Looks like during the validation of AorB it is incorrectly considering c as an extraneous property.
dsagal commented
Thanks for reporting! Just fixed.
mdesousa commented
Awesome! Thanks.