🎩 You're Invited:Meet the Socket team at Black Hat in Las Vegas, August 3-6.RSVP
Sign In

@kenyip/joi

Package Overview
Dependencies
Maintainers
1
Versions
5
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

@kenyip/joi

Object schema validation

latest
Source
npmnpm
Version
0.0.5
Version published
Weekly downloads
2
-84.62%
Maintainers
1
Weekly downloads
 
Created
Source

@kenyip/joi

Forked from joi (version 14.3.1). Adding some convenient functions like removeKey, toSwagger ... etc

Installation

// Using NPM
$ npm i @kenyip/joi --save
// Using Yarn
$ yarn add @kenyip/joi

Plugins

A list of plugins added into Joi framework

toSwagger

Convert the Joi schema objects into Swagger OAS 3.0 schema definitions. The library is cloned from joi-to-swagger with a little bit modification. Click here for the usage and the support conventions.


const object = Joi.object({
		hello: Joi.string(),
		world: Joi.string()
});

console.log(JSON.stringify(objectA.toSwagger(), null, 4));

{
	"type": "object",
	"properties": {
		"hello": {
			"type": "string"
		},
		"world": {
			"type": "string"
		}
	}
}

remove

Remove keys from the existing schema

const objectA = Joi.object({
		hello: Joi.string(),
		world: Joi.string(),
});

const objectB = objectA
		.keys({ foo: Joi.string() })
		.remove(["hello"]);

console.log(JSON.stringify(objectB.toSwagger(), null, 4));

// {
// 	"type": "object",
// 	"properties": {
// 		"world": {
// 			"type": "string"
// 		},
// 		"foo": {
// 			"type": "string"
// 		}
// 	}
// }

Keywords

hapi

FAQs

Package last updated on 20 May 2022

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