source: imaps-frontend/node_modules/webpack/lib/util/create-schema-validation.js@ 79a0317

main
Last change on this file since 79a0317 was 79a0317, checked in by stefan toskovski <stefantoska84@…>, 2 weeks ago

F4 Finalna Verzija

  • Property mode set to 100644
File size: 1.2 KB
Line 
1/*
2 MIT License http://www.opensource.org/licenses/mit-license.php
3 Author Tobias Koppers @sokra
4*/
5
6"use strict";
7
8const memoize = require("./memoize");
9
10/** @typedef {import("schema-utils/declarations/validate").ValidationErrorConfiguration} ValidationErrorConfiguration */
11/** @typedef {import("./fs").JsonObject} JsonObject */
12
13const getValidate = memoize(() => require("schema-utils").validate);
14
15/**
16 * @template {object | object[]} T
17 * @param {(function(T): boolean) | undefined} check check
18 * @param {() => JsonObject} getSchema get schema fn
19 * @param {ValidationErrorConfiguration} options options
20 * @returns {function(T=): void} validate
21 */
22const createSchemaValidation = (check, getSchema, options) => {
23 getSchema = memoize(getSchema);
24 return value => {
25 if (check && !check(/** @type {T} */ (value))) {
26 getValidate()(
27 getSchema(),
28 /** @type {object | object[]} */
29 (value),
30 options
31 );
32 require("util").deprecate(
33 () => {},
34 "webpack bug: Pre-compiled schema reports error while real schema is happy. This has performance drawbacks.",
35 "DEP_WEBPACK_PRE_COMPILED_SCHEMA_INVALID"
36 )();
37 }
38 };
39};
40
41module.exports = createSchemaValidation;
Note: See TracBrowser for help on using the repository browser.