MCPcopy Index your code
hub / github.com/TruthHun/BookStack / assertProp

Function assertProp

static/vuejs/vue.js:1344–1392  ·  view source on GitHub ↗

* Assert whether a prop is valid.

(
  prop,
  name,
  value,
  vm,
  absent
)

Source from the content-addressed store, hash-verified

1342 * Assert whether a prop is valid.
1343 */
1344function assertProp (
1345 prop,
1346 name,
1347 value,
1348 vm,
1349 absent
1350) {
1351 if (prop.required && absent) {
1352 warn(
1353 'Missing required prop: "' + name + '"',
1354 vm
1355 );
1356 return
1357 }
1358 if (value == null && !prop.required) {
1359 return
1360 }
1361 var type = prop.type;
1362 var valid = !type || type === true;
1363 var expectedTypes = [];
1364 if (type) {
1365 if (!Array.isArray(type)) {
1366 type = [type];
1367 }
1368 for (var i = 0; i < type.length && !valid; i++) {
1369 var assertedType = assertType(value, type[i]);
1370 expectedTypes.push(assertedType.expectedType || '');
1371 valid = assertedType.valid;
1372 }
1373 }
1374 if (!valid) {
1375 warn(
1376 'Invalid prop: type check failed for prop "' + name + '".' +
1377 ' Expected ' + expectedTypes.map(capitalize).join(', ') +
1378 ', got ' + Object.prototype.toString.call(value).slice(8, -1) + '.',
1379 vm
1380 );
1381 return
1382 }
1383 var validator = prop.validator;
1384 if (validator) {
1385 if (!validator(value)) {
1386 warn(
1387 'Invalid prop: custom validator check failed for prop "' + name + '".',
1388 vm
1389 );
1390 }
1391 }
1392}
1393
1394/**
1395 * Assert the type of a value

Callers 1

validatePropFunction · 0.70

Calls 3

validatorFunction · 0.85
assertTypeFunction · 0.70
warnFunction · 0.50

Tested by

no test coverage detected