🍋‍🟩 Just enough JavaScript object validation
  • TypeScript 100%
Find a file
Repository files (latest commit first)
Filename Latest commit message Latest commit date
2025-08-12 06:42:04 +01:00
test exhaustive tests 2024-10-25 07:39:07 +01:00
.gitignore .gitignore 2025-08-12 06:42:04 +01:00
deno.json exhaustive tests 2024-10-25 07:39:07 +01:00
LICENSE v0.1.0 2024-07-22 13:34:30 +01:00
mod.ts improve types / format 2024-10-25 06:44:13 +01:00
package.json improve types / format 2024-10-25 06:44:13 +01:00
README.md README 2025-08-12 06:40:37 +01:00
types.ts improve types / format 2024-10-25 06:44:13 +01:00

🍋‍🟩 jsonlike

Just enough JavaScript object validation.

jsonlike is a tiny < 1kB library used to validate JavaScript objects against a JSON-like schema.

It can:

  • Match properties by primitive types
  • Match arrays of single type values
  • Match nested objects

Usage

import {jsonlike} from '@dbushell/jsonlike';

const json = JSON.parse(`{
  "greeting": "Hello, World!",
  "items": [{"id": 1}, {"id": 2}, {"id": 3}]
}`);

const valid = jsonlike(json, {
  greeting: 'string',
  items: [{id: 'number'}]
});

Notes

Use ArkType, Ajv, or Zod for full schema validation.


MIT License | Copyright © 2024 David Bushell