FastPrepJSON Schema Object Validator
Problems/JSON Schema Object Validator

JSON Schema Object Validator

DocuSign logoDocuSign● HardFULLTIMEONSITE INTERVIEW

Updated Nov 2026

QuestionFunctionExamplesConstraints

Problem statement

Source note: The report gives the steps of the validator and the basic types of rules it supports. It does not say what to do with a broken schema, or which schema format works across languages. We chose those. Our version is about 94% the same as the reported question.

Implement validateObject for a small object-schema language. The inputs schemaJson and objectJson are JSON strings. Return false if either string is malformed or violates the grammar below; otherwise return whether the candidate object satisfies the schema.

Schema grammar

  • The schema root has a nonempty string _type and a properties array.
  • Each property rule has a unique nonempty string name, a type equal to string, number, or boolean, and an optional boolean required that defaults to false.
  • A string rule may include validation, an ASCII regular expression matched against the entire candidate string.
  • A number rule may include limit in the form low-high. Both endpoints are JSON numbers, may be negative, and are inclusive. For example, -10--1 represents the interval from -10 through -1.
  • Fields not described above make the schema invalid. A rule may not use validation or limit with an incompatible type.

Candidate rules

  • The candidate root is an object whose nonempty string _type exactly equals the schema type.
  • Every required property must be present. An optional property may be absent.
  • Every key other than _type must have a schema rule; unknown properties are rejected.
  • Each present value must have the rule's exact primitive JSON type. A boolean is not a number.
  • String regular expressions use full-string matching, and number limits include both endpoints.

To keep results the same in every language, all input characters and decoded JSON strings are printable ASCII, JSON objects may not contain duplicate keys, numbers have at most 12 significant digits with absolute value at most 10^9, the schema contains at most 100 property rules, and recursive JSON nesting is at most 8 levels.

Function

validateObject(schemaJson: String, objectJson: String) → boolean

Examples

Example 1

schemaJson = "{\"_type\":\"Person\",\"properties\":[{\"name\":\"name\",\"type\":\"string\",\"validation\":\"[A-Za-z]+\",\"required\":true},{\"name\":\"age\",\"type\":\"number\",\"limit\":\"10-100\"}]}"objectJson = "{\"_type\":\"Person\",\"name\":\"Steven\",\"age\":35}"return = true

The type matches, the required name is present and matches the full regular expression, and 35 lies inside the inclusive numeric range.

Example 2

schemaJson = "{\"_type\":\"Person\",\"properties\":[{\"name\":\"name\",\"type\":\"string\",\"required\":true}]}"objectJson = "{\"_type\":\"Dog\",\"name\":\"Steven\"}"return = false

The candidate type Dog does not equal the schema type Person.

Example 3

schemaJson = "{\"_type\":\"Person\",\"properties\":[{\"name\":\"name\",\"type\":\"string\"}]}"objectJson = "{\"_type\":\"Person\",\"name\":\"Steven\",\"address\":\"unknown\"}"return = false

The schema has no rule for address, so the unknown property is rejected.

Example 4

schemaJson = "{\"_type\":\"Person\",\"properties\":[]}"objectJson = "{not valid JSON}"return = false

The candidate input is malformed JSON.

Constraints

  • 1 <= schemaJson.length, objectJson.length <= 20000.
  • Every input character and decoded JSON string is printable ASCII.
  • Numbers and numeric endpoints have at most 12 significant digits and absolute value at most 10^9.
  • The schema contains at most 100 property rules with unique names.
  • JSON objects may not contain duplicate keys.
  • Recursive JSON nesting is at most 8 levels.
  • A validation pattern uses the common ASCII subset of regular expressions supported by Java, Python, and C++ ECMAScript syntax.

More DocuSign Onsite Interview questions

  • Count Binary SubstringsONSITE INTERVIEW · Seen Sep 2026
  • Two Positions That Add Up to a TargetPHONE SCREEN · ONSITE INTERVIEW · Seen Sep 2026
  • Compress Consecutive Integer RangesONSITE INTERVIEW · Seen Aug 2026
  • Most Transactions Kept Without Going NegativeONSITE INTERVIEW · Seen May 2025
  • Three-Part Splits With a Light MiddleONSITE INTERVIEW · Seen May 2025
  • Combine Two Sorted Lists Into OneONSITE INTERVIEW · Seen Apr 2022
  • Exact Palindrome CheckPHONE SCREEN · ONSITE INTERVIEW · Seen Apr 2022
  • Paired Words That Share a SubstringONSITE INTERVIEW · Seen Apr 2022
  • Reverse the Characters of a TextPHONE SCREEN · ONSITE INTERVIEW · Seen Apr 2022
  • Reverse the Order of a Linked ListONSITE INTERVIEW · Seen Feb 2020

Similar questions at other companies

  • Spreadsheet Formula DependenciesAmazon Web Services · ONSITE INTERVIEWAmazon Web Services interview questions
  • Spreadsheet With Dependent CellsCharacter.AI · PHONE SCREEN
  • In-Memory Key-Value Store SerializationOpenAI · PHONE SCREENOpenAI interview questions
  • Evaluate Sequential Variable AssignmentsGoogle · ONSITE INTERVIEWGoogle interview questions
  • N-Ary Tree Codec OperationsLinkedIn · ONSITE INTERVIEWLinkedIn interview questions
  • Feature Flag Evaluation EngineCresta · ONSITE INTERVIEWCresta interview questions
  • Number of AtomsAmazon · ONSITE INTERVIEW
  • Highest Bid Campaign MatcherStackAdapt · ONSITE INTERVIEWStackAdapt interview questions
  • Query Log MatchDatadog · PHONE SCREEN · ONSITE INTERVIEWDatadog interview questions
  • File System Shell CommandsHarvey · ONSITE INTERVIEWHarvey interview questions

DocuSign interview experiences

  • DocuSign SWE Intern Interviews: 27 Experiences (Part 2 of 2)
  • DocuSign SWE Intern OA Questions: 53 Experiences (Part 1 of 2)
All DocuSign interview questionsSee DocuSign hiring insights
Saved
class Solution {
    public boolean validateObject(String schemaJson, String objectJson) {
      // write your code here
    }
}

Not a valid String

Checking account…