Huge News!Announcing our $40M Series B led by Abstract Ventures.Learn More
Socket
Sign inDemoInstall
Socket

@cfworker/json-schema

Package Overview
Dependencies
Maintainers
1
Versions
43
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

@cfworker/json-schema

A JSON schema validator that will run on Cloudflare workers. Supports drafts 4, 7, and 2019-09.

  • 1.2.14
  • Source
  • npm
  • Socket score

Version published
Weekly downloads
81K
decreased by-16.91%
Maintainers
1
Weekly downloads
 
Created
Source

@cfworker/json-schema

A JSON schema validator that will run on Cloudflare workers. Supports drafts 4, 7, and 2019-09.

background

Why another JSON schema validator?

Cloudflare workers do not have APIs required by Ajv schema compilation (eval or new Function(code)). If possible use Ajv in a build step to precompile your schema. Otherwise use this library.

usage

  1. Basic

    import { Validator } from '@cfworker/json-schema';
    
    const validator = new Validator({ type: 'number' });
    
    const result = validator.validate(7);
    
  2. Specify meta schema draft

    const validator = new Validator({ type: 'number' }, '4'); // draft-4
    
  3. Add schemas

    const validator = new Validator({
      $id: 'https://foo.bar/baz',
      $ref: '/beep'
    });
    
    validator.addSchema({ $id: 'https://foo.bar/beep', type: 'boolean' });
    

Keywords

FAQs

Package last updated on 01 Jul 2020

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

SocketSocket SOC 2 Logo

Product

  • Package Alerts
  • Integrations
  • Docs
  • Pricing
  • FAQ
  • Roadmap
  • Changelog

Packages

npm

Stay in touch

Get open source security insights delivered straight into your inbox.


  • Terms
  • Privacy
  • Security

Made with ⚡️ by Socket Inc