Skip to content

fix(json-formatter): report every failing field in schema validation - #408

Merged
anurag629 merged 1 commit into
codercops:developfrom
prakashNalla:fix/404-schema-all-errors
Oct 28, 2026
Merged

anurag629 merged 1 commit into
codercops:developfrom
prakashNalla:fix/404-schema-all-errors

Conversation

@prakashNalla

Copy link
Copy Markdown
Contributor

What and why

Schema mode only listed the first failing field. lib/jsonSchema.ts created the validator with new Validator(schema, "2020-12"), and the third argument of @cfworker/json-schema's Validator is shortCircuit, which defaults to true, so validation stopped at the first failure. It now passes false, so with the sample schema and {"user":{"id":1,"name":"","email":"x","age":-1},"meta":{}} the list has id, name, email and age together instead of one at a time. Each field error still comes with its parent's Property "<name>" does not match schema. line, as the first error did before, so that input lists 9 entries.

Closes #404

How I tested this

  • Added "reports every failing field in one pass" to lib/__tests__/jsonSchema.test.ts, with those four fields wrong, checking the exact list. It fails without the change (only #/user/id comes back) and passes with it. The existing tests in the file pass unchanged.
  • npm run lint: 0 errors, the same 11 warnings as on develop.
  • npm run test: 64 files, 2363 tests pass.
  • npm run build: passes.

AI assistance

Claude helped me w/ understand the issue

Type of change

  • Bug fix

Checklist

  • I was assigned the linked issue
  • npm run lint && npm run test && npm run build passes locally
  • Logic changes live in lib/ and have a test in lib/__tests__/
  • For a bug fix: the new test fails without my change
  • No analytics, trackers, or calls that send user data off-device
  • Works in both light and dark themes (if UI changed)
  • Inputs have labels and it works with the keyboard alone (if UI changed)
  • New tool: registry entry, page.tsx, client component, opengraph-image.tsx, and the bug report dropdown are all done

@anurag629 anurag629 left a comment

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Thanks @prakashNalla. Lint (develop's 11 warnings), all 2382 tests, the build and the pages pass on top of develop, and the example from #404 now lists id, name, email and age in one go.

@anurag629 anurag629 added the hacktoberfest-accepted PR counts for Hacktoberfest label Oct 28, 2026
@anurag629
anurag629 merged commit 6bf1015 into codercops:develop Oct 28, 2026
3 checks passed
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

hacktoberfest-accepted PR counts for Hacktoberfest

Projects

None yet

Development

Successfully merging this pull request may close these issues.

JSON Formatter: Schema validation only reports the first failing field

2 participants