MCPcopy
hub / github.com/webpack/webpack / validate

Method validate

lib/Compiler.js:1497–1530  ·  lib/Compiler.js::Compiler.validate

* Schema validation function with optional pre-compiled check * @template {EXPECTED_OBJECT | EXPECTED_OBJECT[]} [T=EXPECTED_OBJECT] * @param {Schema | (() => Schema)} schema schema * @param {T} value value * @param {ValidationErrorConfiguration=} options options * @param {((value: T) => bo

(schema, value, options, check)

Source from the content-addressed store, hash-verified

1495 * @param {((value: T) => boolean)=} check options
1496 */
1497 validate(schema, value, options, check) {
1498 class="cm">// Avoid validation at all when disabled
1499 if (this.options.validate === false) {
1500 return;
1501 }
1502
1503 /**
1504 * Returns schema.
1505 * @returns {Schema} schema
1506 */
1507 const getSchema = () => {
1508 if (typeof schema === class="st">"function") {
1509 return schema();
1510 }
1511
1512 return schema;
1513 };
1514
1515 class="cm">// // If we have precompiled schema let's use it
1516 if (check) {
1517 if (!check(value)) {
1518 getValidate()(getSchema(), value, options);
1519 require(class="st">"util").deprecate(
1520 () => {},
1521 class="st">"webpack bug: Pre-compiled schema reports error while real schema is happy. This has performance drawbacks.",
1522 class="st">"DEP_WEBPACK_PRE_COMPILED_SCHEMA_INVALID"
1523 )();
1524 }
1525 return;
1526 }
1527
1528 class="cm">// Otherwise let's standard validation
1529 getValidate()(getSchema(), value, options);
1530 }
1531}
1532
1533module.exports = Compiler;

Callers 15

applyMethod · 0.80
applyMethod · 0.80
applyMethod · 0.80
applyMethod · 0.80
_applyOnCompilerMethod · 0.80
applyMethod · 0.80
applyMethod · 0.80
applyMethod · 0.80
applyMethod · 0.80
applyMethod · 0.80
applyMethod · 0.80
applyMethod · 0.80

Calls 3

checkFunction · 0.50
getSchemaFunction · 0.50
requireFunction · 0.50

Tested by 1