Skip to main content
Home

Built and signed on GitHub Actions

Just enough JavaScript object validation.

This package works with Cloudflare Workers, Node.js, Deno, Bun, Browsers
This package works with Cloudflare Workers
This package works with Node.js
This package works with Deno
This package works with Bun
This package works with Browsers
JSR Score
100%
Published
9 months ago (0.3.0)

🍋‍🟩 jsonlike

JSR NPM

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 Ajv or Zod for full schema validation.


MIT License | Copyright © 2024 David Bushell

Built and signed on
GitHub Actions

New Ticket: Report package

Please provide a reason for reporting this package. We will review your report and take appropriate action.

Please review the JSR usage policy before submitting a report.

Add Package

deno add jsr:@dbushell/jsonlike

Import symbol

import * as jsonlike from "@dbushell/jsonlike";
or

Import directly with a jsr specifier

import * as jsonlike from "jsr:@dbushell/jsonlike";

Add Package

pnpm i jsr:@dbushell/jsonlike
or (using pnpm 10.8 or older)
pnpm dlx jsr add @dbushell/jsonlike

Import symbol

import * as jsonlike from "@dbushell/jsonlike";

Add Package

yarn add jsr:@dbushell/jsonlike
or (using Yarn 4.8 or older)
yarn dlx jsr add @dbushell/jsonlike

Import symbol

import * as jsonlike from "@dbushell/jsonlike";

Add Package

vlt install jsr:@dbushell/jsonlike

Import symbol

import * as jsonlike from "@dbushell/jsonlike";

Add Package

npx jsr add @dbushell/jsonlike

Import symbol

import * as jsonlike from "@dbushell/jsonlike";

Add Package

bunx jsr add @dbushell/jsonlike

Import symbol

import * as jsonlike from "@dbushell/jsonlike";