Skip to content

fix: accept null for nullable tuple items - #908

Open
RaphaelFakhri wants to merge 1 commit into
fastify:mainfrom
RaphaelFakhri:fix/tuple-nullable-items
Open

RaphaelFakhri wants to merge 1 commit into
fastify:mainfrom
RaphaelFakhri:fix/tuple-nullable-items

Conversation

@RaphaelFakhri

Copy link
Copy Markdown

When items is a list of schemas, each item is checked with buildArrayTypeCondition() before it is serialized. That check ignores nullable, so a tuple item such as { type: 'integer', nullable: true } throws Item at 0 does not match schema definition. for null. A nullable single items schema or object property already accepts null.

This change adds buildTupleItemCondition(), which lets null through when the item schema has nullable: true. buildValue() already serializes it as null. Both the inlined and the function-wrapped tuple paths use the new helper. Non-nullable tuple items still reject null.

Fixes #907

Checklist

  • run npm run test && npm run benchmark --if-present (tests pass; benchmark not run)
  • 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

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.

Tuple items with nullable: true reject null

1 participant