Implement a nested object validator

Quick Overview

This question evaluates proficiency in nested data validation, schema interpretation, and type checking for hierarchical objects, including handling nulls, arrays, extra fields, and clear error reporting.

Implement a nested object validator

Company: Applied Intuition

Role: Software Engineer

Category: Data Manipulation (SQL/Python)

Difficulty: medium

Interview Round: Onsite

Implement a helper function validate(object, required_style) that checks whether a possibly nested object matches a provided schema. The object may contain nested sub-objects (e.g., under keys like "OBJ") and arbitrary key–value pairs; required_style is a dictionary mapping field names to required primitive types (e.g., string, integer) or to nested schemas. The function should return a boolean and, if invalid, an explanation including the offending path and reason (missing key, unexpected type). Define how to treat extra fields (ignore or flag), nulls, and arrays. Demonstrate your approach on an example object containing fields like name, age, school, and nested attributes (e.g., color, height) and show how required_style would be expressed.

Quick Answer: This question evaluates proficiency in nested data validation, schema interpretation, and type checking for hierarchical objects, including handling nulls, arrays, extra fields, and clear error reporting.

|Home/Data Manipulation (SQL/Python)/Applied Intuition
Applied Intuition logo
Applied Intuition
Sep 6, 2025, 12:00 AM
mediumSoftware EngineerOnsiteData Manipulation (SQL/Python)
16
0

Implement a helper function validate(object, required_style) that checks whether a possibly nested object matches a provided schema. The object may contain nested sub-objects (e.g., under keys like "OBJ") and arbitrary key–value pairs; required_style is a dictionary mapping field names to required primitive types (e.g., string, integer) or to nested schemas. The function should return a boolean and, if invalid, an explanation including the offending path and reason (missing key, unexpected type). Define how to treat extra fields (ignore or flag), nulls, and arrays. Demonstrate your approach on an example object containing fields like name, age, school, and nested attributes (e.g., color, height) and show how required_style would be expressed.

Loading comments...