I have the following problem. Let's say I have a type:
type A = {
prop1: string,
prop2: {
prop3: string
}
}
I am receiving some json object from an external service and I want to validate if that json matches type A:
function isA(obj:any): boolean {
// What should be here?
}
So if my obj is something like:
{
prop1: "Hello",
prop2: {
prop3: "World"
}
}
or
{
prop1: "Hello",
prop2: {
prop3: "World"
},
moreProps: "I don't care about"
}
The function would return true, but false for something like
{
foo: "Hello",
bar: {
prop3: "World"
}
}
What's the easiest way to achieve this?
Thanks.