You're Invited:Meet the Socket Team at BlackHat and DEF CON in Las Vegas, Aug 4-6.RSVP
Socket
Book a DemoInstallSign in
Socket

@dbushell/jsonlike

Package Overview
Dependencies
Maintainers
1
Versions
4
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

@dbushell/jsonlike

Just enough JavaScript object validation.

0.3.0
latest
Source
npmnpm
Version published
Weekly downloads
2
Maintainers
1
Weekly downloads
 
Created
Source

🍋‍🟩 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

Keywords

json

FAQs

Package last updated on 25 Oct 2024

Did you know?

Socket

Socket for GitHub automatically highlights issues in each pull request and monitors the health of all your open source dependencies. Discover the contents of your packages and block harmful activity before you install or update your dependencies.

Install

Related posts