Design a JSON Schema Validator

Quick Overview

Design a robust JSON schema validator covering parsing, required and unknown fields, types, regexes, numeric limits, and safe extensibility.

Design a JSON Schema Validator

Company: DocuSign

Role: Software Engineer

Category: Software Engineering Fundamentals

Difficulty: easy

Interview Round: Onsite

# Design a JSON Schema Validator Design and implement a validator that accepts a schema JSON string and an object JSON string. Validate the declared object type, required and unknown properties, primitive types, full-string regex constraints, numeric ranges, and malformed JSON, then explain how the design could grow to nested objects, arrays, enums, nullable fields, and recursion. ### Constraints & Assumptions - Unknown properties are rejected unless a clarified schema option allows them. - A numeric range includes both endpoints. - Malformed schema or data JSON fails validation without crashing. ### Clarifying Questions to Ask - How are integer and floating-point values distinguished from booleans? - Are regexes anchored implicitly through full-string matching? - How should contradictory or malformed schema rules be reported? ```hint Separate compilation from validation Normalize property definitions into an internal schema representation before walking data values. ``` ### What a Strong Answer Covers - Deterministic parsing and top-level type checks. - Required, optional, unknown, primitive-type, regex, and range behavior. - An extensible validator interface rather than a class per field name. - Error reporting, complexity, malformed input, nesting, and cycle protection. ### Follow-up Questions 1. How would you return all validation errors instead of the first? 2. How would you cache compiled schemas safely?

Overview: Design a robust JSON schema validator covering parsing, required and unknown fields, types, regexes, numeric limits, and safe extensibility.

|Home/Software Engineering Fundamentals/DocuSign
DocuSign logo
DocuSign
Aug 27, 2026
easySoftware EngineerOnsiteSoftware Engineering Fundamentals
0
0

Design a JSON Schema Validator

Design and implement a validator that accepts a schema JSON string and an object JSON string. Validate the declared object type, required and unknown properties, primitive types, full-string regex constraints, numeric ranges, and malformed JSON, then explain how the design could grow to nested objects, arrays, enums, nullable fields, and recursion.

Constraints & Assumptions

  • Unknown properties are rejected unless a clarified schema option allows them.
  • A numeric range includes both endpoints.
  • Malformed schema or data JSON fails validation without crashing.

Clarifying Questions to Ask Guidance

  • How are integer and floating-point values distinguished from booleans?
  • Are regexes anchored implicitly through full-string matching?
  • How should contradictory or malformed schema rules be reported?

What a Strong Answer Covers Guidance

  • Deterministic parsing and top-level type checks.
  • Required, optional, unknown, primitive-type, regex, and range behavior.
  • An extensible validator interface rather than a class per field name.
  • Error reporting, complexity, malformed input, nesting, and cycle protection.

Follow-up Questions Guidance

  1. How would you return all validation errors instead of the first?
  2. How would you cache compiled schemas safely?
Loading comments...