Write a function to validate a deeply nested object structure against a given schema.
HardProblem Statement
Write a function to validate a deeply nested object structure against a given schema.
Sample Input
Object: { name: "John", details: { age: 30, city: "New York" } }
Schema: { name: "string", details: { age: "number", city: "string" } }Sample Output
Object is valid: true
Limits
Time: 2s · Memory: 256 MB
Code Editor
00:00
function validateObject(obj: any, schema: any): boolean {
// Your logic here
}
Input
Object: { name: "John", details: { age: 30, city: "New York" } }
Schema: { name: "string", details: { age: "number", city: "string" } }Expected Output
Object is valid: true