Skip to content

Return chainable ObjectSchema from extend#302

Open
aouxwoux wants to merge 1 commit into
fastify:mainfrom
aouxwoux:codex/chainable-object-extend
Open

Return chainable ObjectSchema from extend#302
aouxwoux wants to merge 1 commit into
fastify:mainfrom
aouxwoux:codex/chainable-object-extend

Conversation

@aouxwoux

@aouxwoux aouxwoux commented Jul 1, 2026

Copy link
Copy Markdown

Checklist

  • run npm run test and npm run lint
  • tests and/or benchmarks are included
  • documentation is changed or added
  • commit message and code follows the Developer's Certification of Origin and the Code of conduct

Description

ObjectSchema.extend() currently returns a reduced object containing only a few schema methods. That keeps valueOf() working, but breaks normal fluent chaining such as .prop(), .without(), or .only() after extending a schema.

This changes extend() to return the full ObjectSchema instance created from the merged state, preserving the existing merged output while keeping the builder API chainable.

Fixes #249

Notes

No docs update was needed; this restores the expected fluent behavior described by the existing API.

Tests

  • node --test test/ObjectSchema.test.js
  • pnpm exec eslint lib/ObjectSchema.js test/ObjectSchema.test.js
  • pnpm exec c8 --100 node --test
  • pnpm exec tstyche

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.

ObjectSchema.extend Does not return a schema instance

1 participant