Skip to content

Hack workaround for multiple-extend #75

Closed
@dfee

Description

@dfee

🐛 Bug Report

multiple extend was broken here: #69
it was sort of fixed here: #74

however, the result is the hack function below to extend multiple times:

export const extendMultiple = (...schemas: ObjectSchema[]): ObjectSchema =>
  schemas.reduce((prev, curr) => curr.extend(prev), S.object());

To Reproduce

// extend is not a function (technically, the second extend doesn't exist)
S.object().extend(S.object()).extend(S.object())
// ...or
const schema = extendMultiple(S.object(), S.object(), S.object());

Expected behavior

extend shouldn't be excluded from the return value here: https://github.com/fastify/fluent-schema/blob/5ffffb8110a6fe845ca6cd7bbaaf2dc358960b5a/src/ObjectSchema.js#L261-L278

Your Environment

  • node version: 12
  • os: Mac,
  • fluent-schema version: 1.0.3

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions