Problem, as an interviewer would state it:
"Implement a minimal validate(schema, data) supporting a real subset of JSON Schema: type, required, properties, items, and minimum — returning every validation error found, with the exact path to each one."
Examples:
validate({ type: "object", required: ["name"], properties: { name: { type: "string" } } }, { });
// { valid: false, errors: ["$: missing required property \"name\""] }
Clarifying questions expected:
- Should validation stop at the FIRST error, or collect every error across the whole structure?
- Does each error need to report the exact PATH to the offending field, for real usability?
- Which real JSON Schema keywords are actually in scope — the full real spec, or a deliberately small subset?
Code / implementation expected: Yes — real, direct proof across 5 scenarios: fully valid data, a missing required field, a wrong type, a below-minimum number, and an invalid nested array item type.