GithubHelp home page GithubHelp logo

marco-ca / json-schema-strictly-typed Goto Github PK

View Code? Open in Web Editor NEW

This project forked from meeshkan/json-schema-strictly-typed

0.0 1.0 0.0 91 KB

Strict typings for JSON schema

License: MIT License

JavaScript 0.15% TypeScript 99.85%

json-schema-strictly-typed's Introduction

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

json-schema-strictly-typed's People

Watchers

James Cloos avatar

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    ๐Ÿ–– Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. ๐Ÿ“Š๐Ÿ“ˆ๐ŸŽ‰

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google โค๏ธ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.