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

json-schema-strictly-typed

Package Overview
Dependencies
Maintainers
1
Versions
15
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

json-schema-strictly-typed

[![CircleCI](https://circleci.com/gh/unmock/json-schema-fast-check.svg?style=svg)](https://circleci.com/gh/unmock/json-schema-fast-check) [![codecov](https://codecov.io/gh/unmock/json-schema-fast-check/branch/master/graph/badge.svg)](https://codecov.io/g

  • 0.0.14
  • latest
  • npm
  • Socket score

Version published
Weekly downloads
43K
increased by16.14%
Maintainers
1
Weekly downloads
 
Created
Source

CircleCI codecov

json-schema-strictly-typed

JSON Schema is a useful way to define input and output schemas.

Typescript is a useful way to verify the types of JavaScript objects.

json-schema-strictly-typed implements a strict flavor of the JSON Schema 7 specification for typing. By strict, we mean that it is organized into logical types that represent real usage, disallowing certain "nonsense" combinations of fields.

Example

import { JSSTInteger } from "json-schema-strictly-typed";

test("my schema is an integer", () => {
    JSSTInteger.is({ type: "integer" });
});

API

Here are all of the types in the API. Some of them also have sub-types for useful validation. In addition to canonical JSON Schema 6, we have added an optional faker field to the string type to use faker-like packages.

  • JSSTEmpty
  • JSSTConst
  • JSSTReference
  • JSSTNull
  • JSSTBoolean
  • JSSTInteger
    • JSSTSimpleInteger
    • JSSTIntegerWithMinimum
    • JSSTIntegerWithMaximum
    • JSSTIntegerWithBounds
    • JSSTIntegerWithNumericExclusiveBounds
    • JSSTIntegerWithNumericExclusiveMaximum
    • JSSTIntegerWithNumericExclusiveMinimum
    • JSSTIntegerEnum
  • JSSTNumber
    • JSSTSimpleNumber
    • JSSTNumberEnum
  • JSSTString
    • JSSTSimpleString
    • JSSTRegex
    • JSSTStringEnum
  • JSSTArray
    • JSSTList
    • JSSTTuple
  • JSSTObject
  • JSSTOneOf
  • JSSTAnyOf
  • JSSTAllOf
  • JSSTNot

Additionally, top-level versions of all of these are available by adding TopLevel to the definition. Top-level JSON Schema objects contain optional fields like $id, $schema and definitions.

Todo

There is plenty of stuff that is not implemented yet. I'd really appreciate your help!

  • finish implementing the JSON Schema 7 Specification
  • add various schema extensions
  • use XOR combinator instead of | for types to avoid nonsense unoins

FAQs

Package last updated on 06 Sep 2019

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