Skip to content

feat: add helper to register TypeBox string formats#265

Open
drewnetic wants to merge 3 commits intofastify:mainfrom
drewnetic:feat/register-typebox-formats
Open

feat: add helper to register TypeBox string formats#265
drewnetic wants to merge 3 commits intofastify:mainfrom
drewnetic:feat/register-typebox-formats

Conversation

@drewnetic
Copy link
Copy Markdown

@drewnetic drewnetic commented Jan 3, 2026

What’s changed

This PR adds an official helper to register common string formats
(date, date-time, email, uuid, etc.) when using
TypeBoxValidatorCompiler.

Why

Fastify’s default AJV setup enables ajv-formats out of the box,
but TypeBox does not register formats automatically.
This helper avoids copy/paste workarounds and keeps behavior explicit,
without introducing breaking changes.

Notes

  • Formats are registered only when the helper is called
  • Works for both CJS and ESM builds
  • Includes runtime and type tests

Closes #84

Checklist

Comment thread formats.ts Outdated
Comment thread index.mts Outdated
Comment thread test/index.js Outdated
@drewnetic drewnetic requested a review from ilteoood January 20, 2026 01:29
@drewnetic drewnetic force-pushed the feat/register-typebox-formats branch from 9e77c88 to 6692ace Compare March 5, 2026 17:46
@drewnetic
Copy link
Copy Markdown
Author

Hi @ilteoood, just a gentle ping on this since it's been a few weeks!

As mentioned below, I had already addressed all your feedback. I just pushed a tiny commit today to fix a small typo in the tests (uri to url) and clean up a stray semicolon.

Everything should be good to go now! Let me know if you need anything else.

Comment thread README.md Outdated
@ilteoood ilteoood self-requested a review March 6, 2026 16:36
drewnetic and others added 3 commits March 9, 2026 11:15
Co-authored-by: Matteo Pietro Dazzi <matteopietro.dazzi@gmail.com>
Signed-off-by: Andrew Gouvêa Gonçalves de Souza  <103960552+drewnetic@users.noreply.github.com>
@drewnetic drewnetic force-pushed the feat/register-typebox-formats branch from 45c8ded to 5231040 Compare March 9, 2026 14:29
@drewnetic
Copy link
Copy Markdown
Author

Hi @ilteoood, just a quick update: I noticed the recent architectural changes for TS 5.9, so I went ahead and rebased this branch to resolve the merge conflicts. Everything is properly migrated to the new .ts setup and all tests are green again. Ready whenever you are! 🚀

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.

Type.String({ format: "date" }) doesn't work in body validator

2 participants