Comparing version 3.2.0 to 3.2.1
### v3.2.1 | ||
* Support array:additionalItems false setting. | ||
### v3.2.0 | ||
@@ -3,0 +7,0 @@ |
@@ -11,3 +11,2 @@ 'use strict'; | ||
const optionsSchema = Joi.object({ | ||
joischema: Joi.boolean().default(false), | ||
subSchemas: Joi.object().unknown(true).allow(null), | ||
@@ -20,3 +19,3 @@ types: Joi.object().unknown(true).allow(null), | ||
const enjoi = function (schema, options = {}) { | ||
const validateSchema = Joi.validate(schema, schemaSchema); | ||
@@ -29,5 +28,5 @@ | ||
Hoek.assert(!validateOptions.error, validateOptions.error); | ||
const { joischema, subSchemas, types, refineType, strictMode } = validateOptions.value; | ||
const { subSchemas, types, refineType, strictMode } = validateOptions.value; | ||
function resolve(current) { | ||
@@ -65,2 +64,3 @@ if (current.type) { | ||
//Fall through to whatever. | ||
//eslint-disable-next-line no-console | ||
console.warn('WARNING: schema missing a \'type\' or \'$ref\' or \'enum\': %s', JSON.stringify(current)); | ||
@@ -75,6 +75,5 @@ return Joi.any(); | ||
return value.map(function (v) { return resolve(v); }); | ||
} else { | ||
// it's a single entity, so just resolve it normally | ||
return [resolve(value)]; | ||
} | ||
// it's a single entity, so just resolve it normally | ||
return [resolve(value)]; | ||
} | ||
@@ -245,9 +244,18 @@ | ||
let joischema = Joi.array(); | ||
let items; | ||
if (current.items) { | ||
joischema = joischema.items(resolveAsArray(current.items)); | ||
} else if (current.ordered) { | ||
joischema = joischema.ordered(resolveAsArray(current.ordered)); | ||
items = resolveAsArray(current.items); | ||
joischema = joischema.items(items); | ||
} | ||
else if (current.ordered) { | ||
items = resolveAsArray(current.ordered); | ||
joischema = joischema.ordered(items); | ||
} | ||
if (items && current.additionalItems === false) { | ||
joischema = joischema.max(items.length); | ||
} | ||
Util.isNumber(current.minItems) && (joischema = joischema.min(current.minItems)); | ||
@@ -366,3 +374,3 @@ Util.isNumber(current.maxItems) && (joischema = joischema.max(current.maxItems)); | ||
schema = failed ? item.otherwise : item.then; | ||
if (!schema) { | ||
@@ -387,2 +395,2 @@ continue; | ||
module.exports = enjoi; | ||
module.exports = enjoi; |
{ | ||
"name": "enjoi", | ||
"version": "3.2.0", | ||
"version": "3.2.1", | ||
"license": "Apache 2.0", | ||
@@ -10,4 +10,3 @@ "description": "Converts json-schema to Joi schema for validation.", | ||
"cover": "istanbul cover tape -- test/*.js", | ||
"lint": "jshint -c .jshintrc lib/*.js", | ||
"bench": "node test/bench/run.js" | ||
"lint": "eslint lib" | ||
}, | ||
@@ -40,6 +39,6 @@ "repository": { | ||
"devDependencies": { | ||
"eslint": "^4.15.0", | ||
"istanbul": "^0.4.5", | ||
"jshint": "^2.9.5", | ||
"tape": "^4.8.0" | ||
} | ||
} |
@@ -9,11 +9,7 @@ [![Build Status](https://travis-ci.org/tlivings/enjoi.png)](https://travis-ci.org/tlivings/enjoi) [![NPM version](https://badge.fury.io/js/enjoi.png)](http://badge.fury.io/js/enjoi) | ||
`enjoi` is built against json-schema v4, but does not support all of json-schema (yet). | ||
`enjoi` is built against json-schema v4, but does not support all of json-schema. | ||
Here is a list of some missing keyword support still being worked on: | ||
- `not` | ||
- `format` | ||
- `object:patternProperties` | ||
- `array:items` (supports as single schema, not supported as array of schemas). | ||
- `array:additionalItems` | ||
- `object:patternProperties` - Joi limitation. | ||
@@ -20,0 +16,0 @@ ### API |
Major refactor
Supply chain riskPackage has recently undergone a major refactor. It may be unstable or indicate significant internal changes. Use caution when updating to versions that include significant changes.
Found 1 instance in 1 package
18991
301
113
1