@hapipal/toys
Advanced tools
Comparing version
@@ -450,2 +450,15 @@ 'use strict'; | ||
exports.patchJoiSchema = (schema) => { | ||
const keys = Object.keys(schema.describe().keys || {}); | ||
// Make all keys optional, do not enforce defaults | ||
if (keys.length) { | ||
schema = schema.fork(keys, (s) => s.optional()); | ||
} | ||
return schema.prefs({ noDefaults: true }); | ||
}; | ||
// Looks like a realm | ||
@@ -452,0 +465,0 @@ internals.isRealm = (obj) => obj && obj.hasOwnProperty('pluginOptions') && obj.hasOwnProperty('modifiers'); |
{ | ||
"name": "@hapipal/toys", | ||
"version": "3.0.0", | ||
"version": "3.1.0", | ||
"description": "The hapi utility toy chest", | ||
@@ -49,4 +49,5 @@ "main": "lib/index.js", | ||
"@hapi/lab": "24.x.x", | ||
"coveralls": "3.x.x" | ||
"coveralls": "3.x.x", | ||
"joi": "17.x.x" | ||
} | ||
} |
@@ -9,6 +9,11 @@ # toys | ||
## Installation | ||
```sh | ||
npm install @hapipal/toys | ||
``` | ||
## Usage | ||
> See also the [API Reference](API.md) | ||
> | ||
> For support below node v12 or hapi v19 see toys v2. | ||
> Toys is intended for use with hapi v19+ and nodejs v12+ (_see v2 for lower support_). | ||
@@ -15,0 +20,0 @@ Toys is a collection of utilities made to reduce common boilerplate in **hapi v19+** projects, aid usage of events and streams in `async` functions (e.g. handlers and server methods), and provide versions of widely-used utilities from [Hoek](https://github.com/hapijs/hoek) optimized to perform well in hot code paths such as route handlers. |
19491
2.11%349
2.35%82
6.49%6
20%