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/validator

v1.0.4

Published

The fastest JSON Schema validator for JavaScript and TypeScript. Supports Draft 06, 07, 2019-09, and 2020-12.

Downloads

413

Readme

jet-validator

The Fastest JSON Schema Validator in JavaScript

npm version License: MIT Bundle Size


🚀 Why jet-validator?

5-44x faster compilation | 26KB gzipped | Zero dependencies | JSON Schema Draft 06-2020-12

jet-validator compiles JSON Schemas into highly optimized validation functions in sub-millisecond time. Unlike traditional validators that interpret schemas at runtime, jet-validator generates specialized code tailored to your exact schema structure.

Built with simplicity in mind.

Just one import for all supported drafts, check full documentation for how to specify draft for $ref keyword for schema 07 and earlier.

Key Features

  • Lightning Fast - 5-44x faster compilation than AJV (sub-millisecond compilation)
  • Highly Compliant - 99.5%+ compliance on JSON Schema Test Suite across all supported drafts
  • 📦 Smaller Bundle - <26KB with built-in format validators and custom error messages(no external packages needed)
  • 📝 Built-in Formats - email, uri, date-time, uuid, and more included (no extra packages!)
  • ⚠️ Custom Error Messages - Flexible error customization with errorMessage keyword
  • 🎯 Zero Dependencies - Pure TypeScript implementation
  • 💪 TypeScript-First - Full type safety out of the box
  • 🔧 Enhanced Features - elseIf conditionals, advanced $data references, custom keywords, custom formats
  • 🔄 Partial AJV Compatibility - Similar API, minimal code changes needed
  • 📊 Multiple Error Modes - Fail-fast or collect all errors
  • 🌐 Async Schema Loading - Load schemas from HTTP, databases, or file systems
  • 🚫 No Infinite Recursion - Smart resolution process prevents stack overflow errors

🛠️ Schema Builder

Want a fluent, type-safe API for building schemas? Check out @jetio/schema-builder:

import { SchemaBuilder, JetValidator } from "@jetio/schema-builder";

const schema = new SchemaBuilder()
  .object()
  .properties({
    name: s => s.string().minLength(2),
    email: s => s.string().format("email"),
    age: s => s.integer().minimum(18)
  })
  .required(["name", "email"])
  .build();

const validator = new JetValidator();
const validate = validator.compile(schema);

The schema-builder package includes this validator, so you get both in one install.

What Fast Compilation Enables

Because compilation is fast (1-5ms for complex schemas), you can:

Compile schemas on-the-fly - No caching required if performance isn't critical
Hot-reload validation rules - Update schemas without restarting
Dynamic schema generation - Build schemas based on user input or config
Per-request validators - Create custom validators for each request context
Faster Startup - Faster cold starts when compiling large numbers of schemas in serverless environments


📦 Installation

npm install @jetio/validator
pnpm add @jetio/validator
yarn add @jetio/validator

🚀 Quick Start

import { JetValidator } from "@jetio/validator";

const jetValidator = new JetValidator();

const schema = {
  type: "object",
  properties: {
    name: { type: "string", minLength: 2 },
    age: { type: "number", minimum: 0, maximum: 120 },
    email: { type: "string", format: "email" },
  },
  required: ["name", "age"],
};

const validate = jetValidator.compile(schema);

// Valid data
console.log(
  validate({
    name: "Alice",
    age: 25,
    email: "[email protected]",
  })
);
// Output: true

// Invalid data
console.log(
  validate({
    name: "A",
    age: 150,
  })
);
// Output: false

console.log(validate.errors);
// Output:
// [{
//   dataPath: '/name',
//   schemaPath: '/properties/name',
//   keyword: 'minLength',
//   message: 'must NOT have fewer than 2 characters'
// },
// {
//   dataPath: '/age',
//   schemaPath: '/properties/age',
//   keyword: 'maximum',
//   message: 'must be <= 120'
// }]

See Getting Started Guide


📊 JSON Schema Compliance

jet-validator supports JSON Schema Draft 06 through 2020-12 with exceptional compliance rates across all drafts.

Compliance Results

All results are from the official JSON Schema Test Suite. Optional tests were skipped. You can view the test code in the test folder of our repository.

Draft 2020-12

jet-validator:

Total tests: 1261
Passed: 1251 (99.2%)
Failed: 10 (0.8%)

AJV (for comparison):

Total tests: 1261
Passed: 1208 (95.8%)
Failed: 53 (4.2%)

dynamicRef.json (4 failures):

  • Multiple dynamic paths edge cases
  • Dynamic scope leaving edge cases

properties.json (1 failure):

  • __proto__ property edge case

required.json (4 failures) - JavaScript object property names __proto__ property edge case

vocabulary.json (1 failure):

  • Custom metaschema with no validation vocabulary

dynamicRef.json (23 failures) - Dynamic reference resolution issues
ref.json (8 failures) - Stack overflow errors with relative URIs (RangeError: Maximum call stack size exceeded)
required.json (4 failures) - JavaScript object property names __proto__ property edge case unevaluatedItems.json (12 failures) - Nested items evaluation
unevaluatedProperties.json (4 failures) - Dynamic reference with unevaluated properties
properties.json (1 failure) - JavaScript object property names
vocabulary.json (1 failure) - Custom metaschema validation


Draft 2019-09

jet-validator:

Total tests: 1227
Passed: 1206 (98.3%)
Failed: 21 (1.7%)

AJV (for comparison):

Total tests: 1227
Passed: 1206 (98.3%)
Failed: 23 (1.7%)

recursiveRef.json (13 failures):

  • $recursiveRef and $recursiveAnchor are intentionally not supported
  • These keywords are confusing and serve little practical purpose
  • Users should upgrade to Draft 2020-12 and use $dynamicRef/$dynamicAnchor instead (much better design)

Other failures:

  • defs.json (1) - Metaschema validation edge case recursiveAnchor
  • properties.json (1) - __proto__ property edge case required.json (4 failures) - JavaScript object property names __proto__ property edge case
  • ref.json (1) - Recursive anchor interaction
  • unevaluatedItems.json (1) - Recursive reference evaluation
  • unevaluatedProperties.json (1) - Recursive reference evaluation
  • vocabulary.json (1) - Custom metaschema (not supported)

ref.json (8 failures) - Stack overflow errors (RangeError: Maximum call stack size exceeded)
required.json (4 failures) - JavaScript object property names
unevaluatedItems.json (3 failures) - Nested items and conditional evaluation
recursiveRef.json (2 failures) - Recursive reference resolution
unevaluatedProperties.json (2 failures) - Conditional evaluation
properties.json (1 failure) - JavaScript object property names
vocabulary.json (1 failure) - Custom metaschema validation


Draft 07

jet-validator:

Total tests: 913
Passed: 908 (99.5%)
Failed: 5 (0.5%)

AJV (for comparison):

Total tests: 913
Passed: 905 (99.1%)
Failed: 8 (0.9%)

properties.json (5 failure):

  • __proto__ property edge case required.json (4 failures) - JavaScript object property names __proto__ property edge case

required.json (4 failures) - JavaScript object property names __proto__ property edge case ref.json (3 failures) - Reference resolution and sibling keywords
properties.json (1 failure) - JavaScript object property names


Draft 06

jet-validator:

Total tests: 829
Passed: 824 (99.4%)
Failed: 5 (0.6%)

AJV: Specific version does not support Draft 06

properties.json (1 failure): required.json (4 failures) - JavaScript object property names __proto__ property edge case

  • __proto__ property edge case

🚫 No Infinite Recursion

Unlike other validators that struggle with certain schema patterns, jet-validator never encounters infinite recursion problems.

Due to our advanced resolution process, jet-validator never has infinite recursion problems.
Unlike other validators which exceed maximum call stack size on certain schemas,
jet-validator's recursion only goes as deep as the data being validated.

THERE IS NO INFINITE RECURSION IN jet-validator.

While AJV encounters stack overflow errors (RangeError: Maximum call stack size exceeded) on schemas with complex relative URI references, jet-validator handles these schemas without issue. Our three-phase resolution process (Collection → Assignment → Resolution) eliminates circular reference problems at compile time.

Learn more about our Resolution Process


📝 Unsupported Keywords

For transparency, here are the keywords jet-validator intentionally does not support:

Draft 2019-09:

  • $recursiveRef / $recursiveAnchor - Confusing design, replaced by better $dynamicRef/$dynamicAnchor in Draft 2020-12
  • $vocabulary - Custom vocabulary system (edge case feature)

Draft 2020-12:

  • $vocabulary - Custom vocabulary system (edge case feature)

Why not support these?

  • $recursiveRef/$recursiveAnchor serve little practical purpose and are confusing. The Draft 2020-12 $dynamicRef/$dynamicAnchor keywords are much better designed.
  • $vocabulary is an edge case feature that adds complexity without significant benefit for most users.

⚡ Performance Benchmarks

Environment: Ubuntu 1.6GHz laptop under realistic load (browser, IDE, system services)

Why under load? Production servers are never idle. These results reflect real-world conditions.

Summary

🚀 Compilation: 19x faster (1.47ms vs 28.29ms) ✅ Valid Data: 58% win rate (36/62) 🛡️ Invalid Data: 73% win rate (45/62) 🏆 Overall: 72% win rate (89/124)

📊 Full Benchmark Report | 📈 Detailed Results

Tested against AJV v8.17.1 using official benchmarks with 65 schemas, 1000 warmups, 10000 iterations, 30 runs per test


Why This Matters

Caching becomes optional instead of mandatory:

// ❌ Other validators: Must cache to avoid compilation overhead
const validateUser = ajv.compile(userSchema); // Cache this!

// ✅ jet-validator: Fast enough to compile on-demand
app.post("/validate", (req, res) => {
  const schema = req.body.schema;
  const validate = jetValidator.compile(schema); // < 2ms
  res.json(validate(req.body.data));
});

🎯 Core Features

Basic Validation

Simple validation with comprehensive error reporting:

const jetValidator = new JetValidator();

const schema = {
  type: "object",
  properties: {
    username: { type: "string", minLength: 3, maxLength: 20 },
    email: { type: "string", format: "email" },
    age: { type: "number", minimum: 18 },
  },
  required: ["username", "email"],
};

const validate = jetValidator.compile(schema);
const result = validate({ username: "jo", email: "invalid" });

console.log(result); // false
console.log(validate.errors); // Detailed error information

See Basic Validation Examples


Schema Compilation & Management

Compile once, validate many times with blazing speed:

// Synchronous compilation
const validate = jetValidator.compile(schema);

// Async compilation (for remote schemas)
const validate = await jetValidator.compileAsync(schema);

// Add schemas to registry for reuse
jetValidator.addSchema(schema, "user-schema");
const validate = jetValidator.getSchema("user-schema");

See Schema Management & Compilation


Configuration Options

Customize validation behavior to match your needs:

const jetValidator = new JetValidator({
  // Error handling
  allErrors: true, // Collect all errors, not just first
  errorMessage: true, // Enable custom error messages

  // Validation strictness
  strict: true, // Strict mode for schema validation
  strictNumbers: true, // Reject NaN and Infinity
  strictRequired: true, // Fail on undefined required properties

  // Data modification
  coerceTypes: true, // Auto-convert types (string → number)
  useDefaults: true, // Apply default values
  removeAdditional: true, // Remove extra properties

  // Format validation
  validateFormats: true, // Enable format validation

  // Performance
  async: true, // Enable async validation
});

See All Configuration Options


Error Handling

Rich, detailed error information with customizable messages:

const jetValidator = new JetValidator({
  allErrors: true,
  errorMessage: true,
});

const schema = {
  type: "object",
  properties: {
    password: {
      type: "string",
      minLength: 8,
      errorMessage: "Password must be at least 8 characters long",
    },
    confirmPassword: {
      type: "string",
      const: { $data: "1/password" },
      errorMessage: "Passwords must match",
    },
  },
};

const validate = jetValidator.compile(schema);
const result = validate({
  password: "short",
  confirmPassword: "different",
});

console.log(validate.errors); // Custom error messages included

Error Object Structure:

{
  dataPath: string;        // Path to invalid data: "/properties/user"
  schemaPath: string;      // Path to schema location: "/properties/user"
  keyword: string;         // Keyword that failed: "minLength"
  fullSchemaPath: string;  // Complete path: "/properties/user/minLength"
  message: string;         // Error message
  params?: object;         // Additional context
}

See Error Handling Guide


Advanced Error Handling

jet-validator provides production-grade error handling out of the box:

Error Utility Methods

Built-in utilities for working with errors:

// Pretty-print errors with hierarchy
jetValidator.logErrors(validate.errors);

// Group errors by field (perfect for forms)
const fieldErrors = jetValidator.getFieldErrors(validate.errors);
// { '/email': ['Invalid format', 'Too short'], '/age': ['Must be positive'] }

// Format as readable string
jetValidator.errorsText(validate.errors, { separator: "\n" });

Custom Error Messages

Schema-level or parent-level customization:

const schema = {
  type: "object",
  properties: {
    email: {
      type: "string",
      format: "email",
      minLength: 5,
    },
  },
  errorMessage: {
    properties: {
      email: {
        type: "Email must be text",
        format: "Invalid email format",
        minLength: "Email too short",
      },
    },
  },
};

See Complete Error Handling Guide


Schema References & Composition

Build modular, reusable schemas with $ref, $dynamicRef, and schema composition:

const schema = {
  $id: "https://example.com/schemas/user.json",
  type: "object",
  properties: {
    profile: { $ref: "#/$defs/profile" },
    address: { $ref: "https://example.com/schemas/address.json" },
  },
  $defs: {
    profile: {
      type: "object",
      properties: {
        name: { type: "string" },
        bio: { type: "string" },
      },
    },
  },
};

// Load remote schemas automatically
const jetValidator = new JetValidator({
  loadSchema: async (uri) => {
    const response = await fetch(uri);
    return response.json();
  },
});

const validate = await jetValidator.compileAsync(schema);

See Schema References & Composition


Meta-Schema System

Validate your schemas before using them (supports JSON Schema Draft 06-2020-12):

const jetValidator = new JetValidator({
  validateSchema: true,
  meta: true,
});

// Your schema is automatically validated against the meta-schema
const validate = jetValidator.compile(schema);
// Throws error if schema is invalid

// Or validate explicitly
const isValid = jetValidator.validateSchema(schema);

See Meta-Schema System


🔥 Advanced Features

Format Validation

Built-in formats plus easy custom format registration:

// Built-in formats (no extra packages needed!)
const schema = {
  type: "object",
  properties: {
    email: { type: "string", format: "email" },
    url: { type: "string", format: "uri" },
    date: { type: "string", format: "date-time" },
    ipv4: { type: "string", format: "ipv4" },
  },
};

// Add custom formats
jetValidator.addFormat("phone", /^\+?[1-9]\d{1,14}$/);

// Or with validation function
jetValidator.addFormat("even-number", {
  type: "number",
  validate: (value) => value % 2 === 0,
});

// Async format validation
jetValidator.addFormat("unique-email", {
  type: "string",
  async: true,
  validate: async (email) => {
    return !(await database.emailExists(email));
  },
});

See Format Validation Guide


$data References

Compare and validate against other values in your data:

const schema = {
  type: "object",
  properties: {
    startDate: { type: "string", format: "date" },
    endDate: {
      type: "string",
      format: "date",
      // endDate must be after startDate
      formatMinimum: { $data: "1/startDate" },
    },
    minPrice: { type: "number" },
    maxPrice: { type: "number" },
    currentPrice: {
      type: "number",
      minimum: { $data: "1/minPrice" },
      maximum: { $data: "1/maxPrice" },
    },
  },
};

const jetValidator = new JetValidator({ $data: true });
const validate = jetValidator.compile(schema);

See $data References Guide


elseIf Conditionals

Enhanced conditional validation without deep nesting:

// Standard JSON Schema (deeply nested)
{
  if: { properties: { type: { const: 'A' } } },
  then: { /* ... */ },
  else: {
    if: { properties: { type: { const: 'B' } } },
    then: { /* ... */ },
    else: { /* ... */ }
  }
}

// jet-validator elseIf (clean and readable)
{
  if: { properties: { type: { const: 'A' } } },
  then: { /* ... */ },
  elseIf: [
    {
      if: { properties: { type: { const: 'B' } } },
      then: { /* ... */ }
    },
    {
      if: { properties: { type: { const: 'C' } } },
      then: { /* ... */ }
    }
  ],
  else: { /* default case */ }
}

See elseIf Keyword Guide


Custom Keywords

Extend jet-validator with your own validation logic:

// Add custom keyword
jetValidator.addKeyword({
  keyword: "isEven",
  type: "number",
  validate: (schema, data) => {
    return data % 2 === 0;
  },
  error: {
    message: "Number must be even",
  },
});

const schema = {
  type: "number",
  isEven: true,
};

const validate = jetValidator.compile(schema);
console.log(validate(4)); // true
console.log(validate(5)); // false

See Custom Keywords Guide


🛠️ Utility Functions

jet-validator exports utility functions that can be used for schema manipulation and debugging:

import {
  getSchemaAtPath,
  getJSONType,
  deepEqual,
  canonicalStringify,
  len_of,
} from "@jetio/validator/utilities";

getSchemaAtPath(schema, path)

Retrieve a sub-schema at a specific JSON Pointer path.

const schema = {
  properties: {
    user: {
      type: "object",
      properties: {
        name: { type: "string", minLength: 2 },
      },
    },
  },
};

const subSchema = getSchemaAtPath(schema, "#/properties/user/properties/name");
// Returns: { type: 'string', minLength: 2 }

Use case: Debugging validation errors - retrieve the exact schema that caused an error.


getJSONType(value)

Get the JSON Schema type of any value (matches JSON Schema type semantics).

getJSONType(42); // 'integer'
getJSONType(3.14); // 'number'
getJSONType([1, 2, 3]); // 'array'
getJSONType(null); // 'null'
getJSONType({}); // 'object'

Use case: Type checking in custom keywords or validation logic.


deepEqual(a, b)

Deep equality comparison (used internally for const keyword).

deepEqual({ a: 1, b: [2, 3] }, { a: 1, b: [2, 3] }); // true
deepEqual({ a: 1 }, { a: 1, b: 2 }); // false

Use case: Comparing complex data structures in tests or custom validators.


canonicalStringify(obj)

Deterministic JSON stringification (sorted keys for consistent hashing).

const obj1 = { b: 2, a: 1 };
const obj2 = { a: 1, b: 2 };

canonicalStringify(obj1) === canonicalStringify(obj2); // true
JSON.stringify(obj1) === JSON.stringify(obj2); // false

Use case: Caching, deduplication, or comparing schemas.


len_of(str)

Get the true Unicode character count (handles surrogate pairs correctly).

len_of("hello"); // 5
len_of("👋🏽"); // 2 (not 4)
len_of("café"); // 4

Use case: Validating minLength/maxLength for strings with emoji or special Unicode characters.


🔄 Migration from AJV

jet-validator has a very similar API to AJV:

// Before (AJV)
import Ajv from "ajv";
const ajv = new Ajv();
const validate = ajv.compile(schema);

// After (jet-validator)
import { JetValidator } from "@jetio/validator";
const jetValidator = new JetValidator();
const validate = jetValidator.compile(schema);

Benefits of switching:

  • ⚡ 19x faster compilation
  • 📦 Smaller bundle size
  • 🎯 Built-in formats and error messages (no separate packages)
  • ✨ Enhanced features (elseIf, better $data)

What's different:

  • Error object structure
  • Custom keywords use different API
  • Meta-schema setup with cli

🎓 When to Use jet-validator

Perfect For:

High-throughput APIs - Validate thousands of requests per second
Dynamic schemas - Generate and compile schemas on-the-fly
Serverless functions - Fast cold starts with quick compilation
Real-time validation - Hot-reload schemas without restart
Complex validation logic - Advanced $data and conditional validation
Bundle size matters - <100KB with all features included

Consider Alternatives If:

⚠️ You need 100% JSON Schema spec compliance (we're at 99.5%)
⚠️ You're already heavily invested in AJV ecosystem with custom plugins (we offer the same custom keywords but contexts are simpler and different, although much more easy to use) ⚠️ You need streaming validation for extremely large documents


🌟 What Makes jet-validator Different?

1. Three-Phase Resolution Process

jet-validator eliminates infinite recursion through a unique resolution approach. Unlike other validators that resolve references during traversal (causing stack overflow), jet-validator:

  1. Collects all references and identifiers
  2. Assigns unique function names to each location when inlining is impossible
  3. Resolves references by replacing them with function calls

This architecture enables both lightning-fast compilation and bulletproof circular reference handling.

Learn more about the resolution process


2. Sub-Millisecond Compilation

Traditional validators:

// Slow: 10-20ms per compilation
const validate = ajv.compile(schema); // Must cache!

jet-validator:

// Fast: 0.7ms per compilation
const validate = jetValidator.compile(schema); // Can recompile!

3. Enhanced Conditionals with elseIf

Avoid deeply nested if/else chains with clean, readable elseIf syntax.


4. Advanced $data Support

Reference and compare values within your data during validation.


5. Built-in Everything

No need for separate packages - formats, error messages, and advanced features are all included.


💡 Common Use Cases

API Request Validation

app.post("/api/users", (req, res) => {
  const validate = jetValidator.compile(userSchema);
  const result = validate(req.body);

  if (!result) {
    return res.status(400).json({ errors: validate.errors });
  }

  // Process valid data
});

Form Validation with Type Coercion

const jetValidator = new JetValidator({ coerceTypes: true });

const formSchema = {
  type: "object",
  properties: {
    age: { type: "number", minimum: 18 },
    agree: { type: "boolean" },
  },
};

const validate = jetValidator.compile(formSchema);

// Automatically converts strings to correct types
const data = { age: "25", agree: "true" };
validate(data);
console.log(data); // { age: '25', agree: 'true' }
// Note: JetValidator does not modify original data objects

Config File Validation

const configSchema = {
  type: "object",
  properties: {
    port: { type: "number", default: 3000 },
    host: { type: "string", default: "localhost" },
    ssl: { type: "boolean", default: false },
  },
};

const jetValidator = new JetValidator({ useDefaults: true });
const validate = jetValidator.compile(configSchema);

const config = {};
validate(config);
console.log(config); // {}
// Note: JetValidator does not modify original data objects

Dynamic Schema Generation

function createValidatorForUser(userType) {
  const schema = {
    type: "object",
    properties: {
      name: { type: "string" },
      role: { const: userType },
    },
  };

  // Fast enough to compile per request
  return jetValidator.compile(schema);
}

const validateAdmin = createValidatorForUser("admin");
const validateUser = createValidatorForUser("user");

📚 Documentation

Quick Navigation

Getting Started:

Core Concepts:

Advanced Features:

Complete Documentation:


Acknowledgments

  • Format validation patterns follow RFC and ISO specifications
  • Inspired by the performance goals of AJV

🤝 Contributing

We welcome contributions! jet-validator is a community project and we appreciate all help.

Ways to Contribute

  • 🐛 Report bugs - Found an issue? Open a bug report
  • 💡 Suggest features - Have an idea? Open a feature request
  • 📖 Improve docs - Fix typos, add examples, clarify explanations
  • 🧪 Add test cases - Contribute to JSON Schema compliance
  • Performance improvements - Make it even faster
  • 🎨 Code contributions - Fix bugs or implement features

Development Setup

# Clone the repo
git clone https://github.com/official-jetio/validator
cd validator

# Install dependencies
npm install

# Build the project
npm run build

# Run JSON Schema Test Suite
npm run test:draft2020-12
npm run test:draft2019-09
npm run test:draft7
npm run test:draft6

# Run all tests
npm run test

# Run benchmarks
node --expose-gc --max-old-space-size=4096 --max-semi-space-size=64 benchmarks/jet-validator-benchmark.js

Testing Philosophy

jet-validator uses the official JSON Schema Test Suite as its primary test suite. This ensures real-world compliance rather than contrived unit tests.

To test your changes:

  1. Make your changes to the codebase
  2. Build: npm run build
  3. Run the official test suite: npm run test:draft2020-12 (or appropriate draft)
  4. Check compliance rate - aim to maintain or improve current 99.5%+ compliance

The test runner (tests/test.ts) validates against:

  • 1,261+ tests for Draft 2020-12
  • 1,227+ tests for Draft 2019-09
  • 913+ tests for Draft 07
  • 829+ tests for Draft 06

Code Contributions

Before submitting a PR:

  1. ✅ Run the test suite and ensure no regressions
  2. ✅ Run npm run build successfully
  3. ✅ Update documentation if you're adding features
  4. ✅ Add benchmark tests if you're optimizing performance
  5. ✅ Explain the "why" in your PR description

Areas that need help:

  • Further optimization of common validation patterns
  • Additional format validators
  • Better error messages
  • Documentation improvements
  • Edge case handling from the test suite

Understanding the Codebase

The resolver (src/compiler/resolver.ts) is the heart of jet-validator. It handles:

  • Schema resolution and reference tracking
  • $ref, $dynamicRef, $anchor resolution
  • External schema loading
  • Circular reference prevention
  • Three-phase resolution process

If you're working on the resolver, please be extra careful - it's complex but battle-tested against 3,000+ official test cases.

Questions?


All contributions are appreciated! Even small improvements help make jet-validator better for everyone.


🐛 Found an Issue?

We track bugs and feature requests using GitHub Issues.

Before Filing an Issue

  1. Search existing issues - Your issue might already be reported
  2. Check the documentation - The answer might be in the 20k+ line docs
  3. Try the latest version - npm install @jetio/validator@latest

Types of Issues

  • 🐛 Bug Report: Something isn't working correctly

  • 💡 Feature Request: Suggest a new feature or improvement

  • Question: Need help or clarification

  • 📖 Documentation: Docs are unclear or missing information

Good Bug Report Template

**Description:** Brief description of the issue

**Schema:**
\`\`\`json
{
"type": "object",
// your schema here
}
\`\`\`

**Data:**
\`\`\`json
{
// your data here
}
\`\`\`

**Expected:** What should happen

**Actual:** What actually happens

**Environment:**

- jet-validator version:
- Node.js version:
- OS:

🔗 Quick Links:


⚠️ Benchmark Methodology & Hardware Notes

Performance on Better Hardware:

Results will vary significantly on better hardware. While absolute numbers will improve across the board, jet-validator is expected to maintain its performance advantages, especially in compilation speed.


🏆 Conclusion

jet-validator has proven itself as a strong contender for JSON Schema validation in the Node.js ecosystem, offering:

99.5% JSON Schema compliance - More spec-compliant than AJV in many areas
🚀 Compilation: 19x faster (1.47ms vs 28.29ms) on average - Game-changer for serverless ✅ Valid Data: 58% win rate (36/62) 🛡️ Invalid Data: 73% win rate (45/62) 🏆 Overall: 72% win rate (89/124)

jet-validator is the clear choice for:

  • Serverless applications (cold start critical)
  • High-volume validation workloads
  • Real-world schema validation
  • Applications requiring fast compilation
  • Security-focused applications (invalid data detection)
  • Heavy reliance on complex $ref graphs
  • Schemas with complex conditional logic
  • Extremely deep composition chains (>10 levels)

Whether jet-validator is the "new king" depends on your use case, but the numbers speak for themselves.


📄 License

MIT © Great Venerable


🔗 Links


Built with ❤️ by The Venerable Supreme