diff --git a/src/ObjectSchema.js b/src/ObjectSchema.js index 26bf978..b21b882 100644 --- a/src/ObjectSchema.js +++ b/src/ObjectSchema.js @@ -340,14 +340,7 @@ const ObjectSchema = ({ schema = initialState, ...options } = {}) => { } const src = base._getState() const extended = combineDeepmerge(src, schema) - const { - valueOf, - isFluentSchema, - FLUENT_SCHEMA, - _getState, - extend - } = ObjectSchema({ schema: extended, ...options }) - return { valueOf, isFluentSchema, FLUENT_SCHEMA, _getState, extend } + return ObjectSchema({ schema: extended, ...options }) }, /** diff --git a/src/ObjectSchema.test.js b/src/ObjectSchema.test.js index a8d7a39..a256867 100644 --- a/src/ObjectSchema.test.js +++ b/src/ObjectSchema.test.js @@ -844,6 +844,25 @@ describe('ObjectSchema', () => { }) }) + it('extends schemas in a chain supporting without after extend', () => { + const base = S.object() + .prop('foo') + + const extended = S.object() + .prop('bar') + .prop('baz') + .extend(base) + .without(['foo']) + assert.deepStrictEqual(extended.valueOf(), { + $schema: 'http://json-schema.org/draft-07/schema#', + type: 'object', + properties: { + bar: {}, + baz: {} + } + }) + }) + it('throws an error if a schema is not provided', () => { assert.throws( () => S.object().extend(), @@ -861,19 +880,6 @@ describe('ObjectSchema', () => { err.message === "Schema isn't FluentSchema type" ) }) - - it('throws an error if you append a new prop after extend', () => { - assert.throws( - () => { - const base = S.object() - S.object().extend(base).prop('foo') - }, - (err) => - // err instanceof S.FluentSchemaError && - err instanceof TypeError && - err.message === 'S.object(...).extend(...).prop is not a function' - ) - }) }) describe('only', () => {