Skip to content

docs: explain toJSON validation with anyOf and oneOf - #892

Open
zanmlakar wants to merge 1 commit into
fastify:mainfrom
zanmlakar:docs/tojson-union-validation
Open

zanmlakar wants to merge 1 commit into
fastify:mainfrom
zanmlakar:docs/tojson-union-validation

Conversation

@zanmlakar

Copy link
Copy Markdown

Document that anyOf and oneOf validate nested objects before calling their toJSON() methods. Properties supplied only by toJSON() therefore cannot satisfy the branch's required properties.

Add a README example showing explicit conversion, plus tests covering both keywords and the direct-object-schema comparison. This documents existing behavior; serialization semantics are unchanged.

Refs #621.

Verified locally on Linux with Node 26.7.0:

  • 588 unit tests and 15 type assertions passed, with 100% configured coverage.
  • All 10 focused toJSON tests passed.
  • Lint, the README example, and all seven benchmark groups passed.

AI assistance: OpenAI Codex helped research the issue, prepare the documentation and tests, and run the listed checks.

This branch has not been deployed

No deployments
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant