schema-utils
Advanced tools
Comparing version 4.0.1 to 4.1.0
@@ -11,2 +11,3 @@ export type JSONSchema4 = import("json-schema").JSONSchema4; | ||
link?: string | undefined; | ||
undefinedAsNull?: boolean | undefined; | ||
}; | ||
@@ -37,2 +38,3 @@ export type Schema = (JSONSchema4 | JSONSchema6 | JSONSchema7) & Extend; | ||
* @property {string=} link | ||
* @property {boolean=} undefinedAsNull | ||
*/ | ||
@@ -39,0 +41,0 @@ /** @typedef {(JSONSchema4 | JSONSchema6 | JSONSchema7) & Extend} Schema */ |
@@ -14,2 +14,3 @@ "use strict"; | ||
var _absolutePath = _interopRequireDefault(require("./keywords/absolutePath")); | ||
var _undefinedAsNull = _interopRequireDefault(require("./keywords/undefinedAsNull")); | ||
var _ValidationError = _interopRequireDefault(require("./ValidationError")); | ||
@@ -61,4 +62,6 @@ function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { default: obj }; } | ||
}); | ||
// Custom keywords | ||
(0, _absolutePath.default)(ajv); | ||
(0, _undefinedAsNull.default)(ajv); | ||
return ajv; | ||
@@ -79,2 +82,3 @@ }); | ||
* @property {string=} link | ||
* @property {boolean=} undefinedAsNull | ||
*/ | ||
@@ -81,0 +85,0 @@ |
@@ -438,4 +438,9 @@ "use strict"; | ||
if (schema.enum) { | ||
return (/** @type {Array<any>} */schema.enum.map(item => JSON.stringify(item)).join(" | ") | ||
); | ||
const enumValues = /** @type {Array<any>} */schema.enum.map(item => { | ||
if (item === null && schema.undefinedAsNull) { | ||
return `${JSON.stringify(item)} | undefined`; | ||
} | ||
return JSON.stringify(item); | ||
}).join(" | "); | ||
return `${enumValues}`; | ||
} | ||
@@ -442,0 +447,0 @@ if (typeof schema.const !== "undefined") { |
{ | ||
"name": "schema-utils", | ||
"version": "4.0.1", | ||
"version": "4.1.0", | ||
"description": "webpack Validation Utils", | ||
@@ -57,3 +57,3 @@ "license": "MIT", | ||
"@babel/preset-env": "^7.16.11", | ||
"@commitlint/cli": "^16.1.0", | ||
"@commitlint/cli": "^17.6.1", | ||
"@commitlint/config-conventional": "^16.0.0", | ||
@@ -70,7 +70,7 @@ "@webpack-contrib/eslint-config-webpack": "^3.0.0", | ||
"jest": "^27.4.7", | ||
"lint-staged": "^12.3.3", | ||
"lint-staged": "^13.2.1", | ||
"npm-run-all": "^4.1.5", | ||
"prettier": "^2.5.1", | ||
"standard-version": "^9.3.2", | ||
"typescript": "^4.5.5", | ||
"typescript": "^4.9.5", | ||
"webpack": "^5.68.0" | ||
@@ -77,0 +77,0 @@ }, |
@@ -16,3 +16,3 @@ <div align="center"> | ||
[![coverage][cover]][cover-url] | ||
[![chat][chat]][chat-url] | ||
[![GitHub Discussions][discussion]][discussion-url] | ||
[![size][size]][size-url] | ||
@@ -285,5 +285,5 @@ | ||
[cover-url]: https://codecov.io/gh/webpack/schema-utils | ||
[chat]: https://badges.gitter.im/webpack/webpack.svg | ||
[chat-url]: https://gitter.im/webpack/webpack | ||
[discussion]: https://img.shields.io/github/discussions/webpack/webpack | ||
[discussion-url]: https://github.com/webpack/webpack/discussions | ||
[size]: https://packagephobia.com/badge?p=schema-utils | ||
[size-url]: https://packagephobia.com/result?p=schema-utils |
82717
18
1776