Coder Social home page Coder Social logo

forivall / is-json-schema-subset Goto Github PK

View Code? Open in Web Editor NEW

This project forked from haggholm/is-json-schema-subset

0.0 2.0 0.0 899 KB

Check to see if input of one JSON schema will be valid according to another schema

License: MIT License

TypeScript 99.33% JavaScript 0.67%

is-json-schema-subset's Introduction

Build Status Greenkeeper badge Coverage Status

is-json-schema-subset

Check if a JSON schema is a subset of another

Given a schema defining the output of some process A, and a second schema defining the input of some process B, will the output from A be valid input for process B?

Uses ajv and json-schema-merge-allof.

Usage

import isJsonSchemaSubset from 'is-json-schema-subset';

import inputSchema from './input-schema.json';
import outputSchema from './input-schema.json';

async function check() {
	if (await isJsonSchemaSubset(inputSchema, outputSchema)) {
		console.log('OK');
	} else {
		console.log('Fail');
	}
}

API

import isJsonSchemaSubset from 'is-json-schema-subset';

isJsonSchemaSubset(subset: JSONSchema, superset: JSONSchema[, allowPartial: boolean = false])

Returns a promise resolving to true if subset is a compatible subset of superset, else false.

If allowPartial is false, subset must provide all required properties for superset.

Install

$ yarn add is-json-schema-subset

Debugging

DEBUG=is-json-schema-subset ...

License

MIT

is-json-schema-subset's People

Contributors

haggholm avatar forivall avatar greenkeeper[bot] avatar

Watchers

James Cloos avatar  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.