npm package discovery and stats viewer.

Discover Tips

  • General search

    [free text search, go nuts!]

  • Package details

    pkg:[package-name]

  • User packages

    @[username]

Sponsor

Optimize Toolset

I’ve always been into building performant and accessible sites, but lately I’ve been taking it extremely seriously. So much so that I’ve been building a tool to help me optimize and monitor the sites that I build to make sure that I’m making an attempt to offer the best experience to those who visit them. If you’re into performant, accessible and SEO friendly sites, you might like it too! You can check it out at Optimize Toolset.

About

Hi, 👋, I’m Ryan Hefner  and I built this site for me, and you! The goal of this site was to provide an easy way for me to check the stats on my npm packages, both for prioritizing issues and updates, and to give me a little kick in the pants to keep up on stuff.

As I was building it, I realized that I was actually using the tool to build the tool, and figured I might as well put this out there and hopefully others will find it to be a fast and useful way to search and browse npm packages as I have.

If you’re interested in other things I’m working on, follow me on Twitter or check out the open source projects I’ve been publishing on GitHub.

I am also working on a Twitter bot for this site to tweet the most popular, newest, random packages from npm. Please follow that account now and it will start sending out packages soon–ish.

Open Software & Tools

This site wouldn’t be possible without the immense generosity and tireless efforts from the people who make contributions to the world and share their work via open source initiatives. Thank you 🙏

© 2026 – Pkg Stats / Ryan Hefner

@jetio/fastify-validator

v1.0.0

Published

Drop-in Fastify schema compiler powered by @jetio/validator - 19x faster compilation than default with full JSON Schema compliance and advanced validation features.

Readme

@jetio/fastify-validator

JetValidator integration for Fastify - 19x faster schema compilation

Drop-in replacement for Fastify's default AJV validator with significantly faster compilation and additional features.

Why?

Fastify uses AJV by default for schema validation. While AJV is excellent, schema compilation can be slow in serverless environments where every millisecond counts.

Compilation speed matters for:

  • ✅ Serverless cold starts (Lambda, Cloud Functions)
  • ✅ Applications with many routes
  • ✅ Dynamic schema generation
  • ✅ Fast server restarts

Performance

Compilation speed:

  • AJV: ~28ms per schema
  • JetValidator: ~1.4ms per schema
  • 19x faster on average

See benchmarks

For 20 routes:

  • AJV: ~560ms compilation time
  • JetValidator: ~28ms compilation time
  • 532ms faster cold start

Installation

npm install @jetio/fastify-validator

Usage

Using createJetValidatorController

import Fastify from 'fastify';
import { createJetValidatorController } from '@jetio/fastify-validator';

const fastify = Fastify({
  schemaController: createJetValidatorController({})
});


// Define routes with schemas as usual
fastify.post('/user', {
  schema: {
    body: {
      type: 'object',
      properties: {
        name: { type: 'string', minLength: 2 },
        email: { type: 'string', format: 'email' },
        age: { type: 'number', minimum: 0 }
      },
      required: ['name', 'email']
    }
  }
}, async (request, reply) => {
  return { success: true, user: request.body };
});

fastify.listen({ port: 3000 });

Using createJetValidatorCompiler

import Fastify from 'fastify';
import { createJetValidatorCompiler } from '@jetio/fastify-validator';

const fastify = Fastify({
  schemaController: {
    compilersFactory: {
      buildValidator: createJetValidatorCompiler({}),
    },
  }
});


// Define routes with schemas as usual
fastify.post('/user', {
  schema: {
    body: {
      type: 'object',
      properties: {
        name: { type: 'string', minLength: 2 },
        email: { type: 'string', format: 'email' },
        age: { type: 'number', minimum: 0 }
      },
      required: ['name', 'email']
    }
  }
}, async (request, reply) => {
  return { success: true, user: request.body };
});

fastify.listen({ port: 3000 });

This is for those who wants just the buildValidator and not the entire schema controller.

Options

All JetValidator options are supported for both createJetValidatorController and createJetValidatorCompiler:

createJetValidatorController({
  allErrors: true,        // Collect all errors
  removeAdditional: true, // Remove extra properties
  coerceTypes: true,      // Auto-convert types
  useDefaults: true,      // Apply default values
  validateFormats: true,  // Enable format validation
  $data: true,            // Enable $data references
  errorMessage: true,     // Custom error messages
  strict: true,            // Strict validation mode
  async: true,
  inlineRefs: false,

  //And more.


  //Including 
  errorFormatter?: (errors: any[]) => Error; // Not in jet validator but needed in fastify.
  //Custom Function for formating jet validator errors.
})

Features

Everything Fastify + AJV supports, plus:

  • 19x faster compilation
  • Full JSON Schema Draft 06-2020-12 support
  • 99.2% spec compliance
  • Json Schema Compliant TypeScript type inference (with @jetio/schema-builder)
  • elseIf conditionals
  • Inbuilt formats and custom error messages
  • Advanced $data references
  • Custom keywords (3 types)
  • Macro system
  • Zero dependencies
  • Meta schema system and cli
  • Advance $ref resolution
  • Stand alone code generation that inlines everything and supports custom keywords

Migration from Deafult Fastify Compiler

Zero code changes to your routes. Just change the Fastify initialization:

const fastify = Fastify();
+ import { createJetValidatorController } from '@jetio/fastify-validator';
+ 
+ const fastify = Fastify({
+   schemaController: createJetValidatorController()
+ });

Everything else stays the same.

Examples

See the examples directory:

Note on Async Validation: While JetValidator supports async validation natively, it is not supported in this Fastify integration. Per Fastify's own recommendation, async logic such as database lookups during validation can lead to Denial of Service vulnerabilities and unhandled promise rejections. Use Fastify's preHandler hooks for async validation tasks instead.

Compatibility

  • Fastify: 4.x, 5.x
  • Node.js: 16+

🔗 Links

📄 License

MIT © Great Venerable


Built with ❤️ for developers who demand full JSON Schema compliance and blazing-fast Fastify startup times.

The Venerable Supreme