0.0.14 • Published 5 years ago

json-schema-strictly-typed v0.0.14

Weekly downloads
688
License
MIT
Repository
-
Last release
5 years ago

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
0.0.14

5 years ago

0.0.13

5 years ago

0.0.12

5 years ago

0.0.11

5 years ago

0.0.10

5 years ago

0.0.9

5 years ago

0.0.8

5 years ago

0.0.7

5 years ago

0.0.6

5 years ago

0.0.5

5 years ago

0.0.4

5 years ago

0.0.3

5 years ago

0.0.2

5 years ago

0.0.1

5 years ago

0.0.0

5 years ago