Skip to content

Commit 7999745

Browse files
committed
feat: define validateWebpackOptions function
Define a function that is used to validate an object against webpackOptionsSchema.json.
1 parent 57ea1ea commit 7999745

2 files changed

Lines changed: 14 additions & 0 deletions

File tree

lib/validateWebpackOptions.js

Lines changed: 13 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,13 @@
1+
/*
2+
MIT License http://www.opensource.org/licenses/mit-license.php
3+
Author Gajus Kuizinas @gajus
4+
*/
5+
var webpackOptionsSchema = require("./../schemas/webpackOptionsSchema.json");
6+
var Ajv = require("ajv");
7+
var ajv = new Ajv();
8+
var validate = ajv.compile(webpackOptionsSchema);
9+
function validateWebpackOptions(options) {
10+
var valid = validate(options);
11+
return valid ? [] : validate.errors;
12+
}
13+
module.exports = validateWebpackOptions;

package.json

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -5,6 +5,7 @@
55
"description": "Packs CommonJs/AMD modules for the browser. Allows to split your codebase into multiple bundles, which can be loaded on demand. Support loaders to preprocess files, i.e. json, jsx, es7, css, less, ... and your custom stuff.",
66
"dependencies": {
77
"acorn": "^3.2.0",
8+
"ajv": "^4.7.0",
89
"async": "^1.3.0",
910
"clone": "^1.0.2",
1011
"enhanced-resolve": "^2.2.0",

0 commit comments

Comments
 (0)