1 |
|
2 |
|
3 |
|
4 |
|
5 |
|
6 | "use strict";
|
7 |
|
8 | const memoize = require("./memoize");
|
9 |
|
10 | const getValidate = memoize(() => require("schema-utils").validate);
|
11 |
|
12 | const createSchemaValidation = (check, getSchema, options) => {
|
13 | getSchema = memoize(getSchema);
|
14 | return value => {
|
15 | if (check && !check(value)) {
|
16 | getValidate()(getSchema(), value, options);
|
17 | if (check) {
|
18 | require("util").deprecate(
|
19 | () => {},
|
20 | "webpack bug: Pre-compiled schema reports error while real schema is happy. This has performance drawbacks.",
|
21 | "DEP_WEBPACK_PRE_COMPILED_SCHEMA_INVALID"
|
22 | )();
|
23 | }
|
24 | }
|
25 | };
|
26 | };
|
27 |
|
28 | module.exports = createSchemaValidation;
|