diff --git a/js/pages/study.js b/js/pages/study.js index 024019f..204606b 100644 --- a/js/pages/study.js +++ b/js/pages/study.js @@ -65,18 +65,20 @@ export default function renderStudy() {
Constraint: no external libraries to keep bundle size minimal. Implemented recursive descent that collects errors instead of failing fast, which keeps the UI responsive for large payloads.
-function validateNode(schema, value, path = '$') {
- const errors = [];
- if (schema.type === 'object') {
- for (const key of schema.required ?? []) {
- if (!(key in value)) errors.push(`${path} missing ${key}`);
- }
- Object.entries(schema.properties ?? {}).forEach(([key, child]) => {
- if (key in value) errors.push(...validateNode(child, value[key], `${path}.${key}`));
- });
- }
- return errors;
-}
+ ${[
+ "function validateNode(schema, value, path = '$') {",
+ " const errors = [];",
+ " if (schema.type === 'object') {",
+ " for (const key of schema.required ?? []) {",
+ " if (!(key in value)) errors.push(`${path} missing ${key}`);",
+ " }",
+ " Object.entries(schema.properties ?? {}).forEach(([key, child]) => {",
+ " if (key in value) errors.push(...validateNode(child, value[key], `${path}.${key}`));",
+ " });",
+ " }",
+ " return errors;",
+ "}"
+ ].join('\n')}
Limitation: draft-07 subset only; no $ref support. Documented in-tool to set expectations.