1.0.1 • Published 4 years ago

serviceberry-json-schema v1.0.1

Weekly downloads
15
License
MIT
Repository
github
Last release
4 years ago

serviceberry-json-schema

CircleCI Test Coverage Maintainability npm version

JSON Schema validator plugin for Serviceberry. For more information visit json-schema.org.

Install

npm install serviceberry-json-schema

Usage

This plugin exports a function that creates handlers. To use this plugin, call this function with a schema object and an optional options object. The second argument can also be a validator instance. Validators are objects with a compileAsync method that returns a validate function (such as a Ajv instance) If an options object is passed, a new Ajv instance is created.

const jsonSchema = require("serviceberry-json-schema");

trunk.use(jsonSchema({
	type: "object",
	properties: {
		firstName: {
			type: "string"
		},
		lastName: {
			type: "string"
		}
	},
	required: [
		"firstName",
		"lastName"
	]
}));

async jsonSchema(schema, param)

async jsonSchema(schema, param)

  • schema object

    JSON Schema

  • param string

    See above

  • validator object

    Ajv instance or any object that has a compileAsync method that takes the schema and returns a validate function.

1.0.1

4 years ago

1.0.0

4 years ago

0.3.0

5 years ago

0.2.0

5 years ago

0.1.3

5 years ago

0.1.1

5 years ago

0.1.0

6 years ago