open-index/open-npm huggingface dataset:
npm package: @kenyip/joi
Description: Object schema validation
Latest version: 0.0.5

# @kenyip/joi

Forked from [joi](https://www.npmjs.com/package/joi) (version 14.3.1). Adding some convenient functions like `removeKey`, `toSwagger` ... etc

## Installation

```shell
// 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](https://www.npmjs.com/package/joi) schema objects into [Swagger](https://swagger.io/) OAS 3.0 schema definitions. The library is cloned from [joi-to-swagger](https://www.npmjs.com/package/joi-to-swagger) with a little bit modification. Click [here](https://www.npmjs.com/package/joi-to-swagger) for the usage and the support conventions. 

```js

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

```js
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"
// 		}
// 	}
// }
```