create-schema-validation.js 711 B

12345678910111213141516171819202122232425262728
  1. /*
  2. MIT License http://www.opensource.org/licenses/mit-license.php
  3. Author Tobias Koppers @sokra
  4. */
  5. "use strict";
  6. const memoize = require("./memoize");
  7. const getValidate = memoize(() => require("schema-utils").validate);
  8. const createSchemaValidation = (check, getSchema, options) => {
  9. getSchema = memoize(getSchema);
  10. return value => {
  11. if (check && !check(value)) {
  12. getValidate()(getSchema(), value, options);
  13. if (check) {
  14. require("util").deprecate(
  15. () => {},
  16. "webpack bug: Pre-compiled schema reports error while real schema is happy. This has performance drawbacks.",
  17. "DEP_WEBPACK_PRE_COMPILED_SCHEMA_INVALID"
  18. )();
  19. }
  20. }
  21. };
  22. };
  23. module.exports = createSchemaValidation;