MCPcopy
hub / github.com/NaiboWang/EasySpider / assertProp

Function assertProp

ElectronJS/src/taskGrid/vue.js:1682–1729  ·  view source on GitHub ↗

* Assert whether a prop is valid.

(
    prop,
    name,
    value,
    vm,
    absent
  )

Source from the content-addressed store, hash-verified

1680 * Assert whether a prop is valid.
1681 */
1682 function assertProp (
1683 prop,
1684 name,
1685 value,
1686 vm,
1687 absent
1688 ) {
1689 if (prop.required && absent) {
1690 warn(
1691 'Missing required prop: "' + name + '"',
1692 vm
1693 );
1694 return
1695 }
1696 if (value == null && !prop.required) {
1697 return
1698 }
1699 var type = prop.type;
1700 var valid = !type || type === true;
1701 var expectedTypes = [];
1702 if (type) {
1703 if (!Array.isArray(type)) {
1704 type = [type];
1705 }
1706 for (var i = 0; i < type.length && !valid; i++) {
1707 var assertedType = assertType(value, type[i]);
1708 expectedTypes.push(assertedType.expectedType || '');
1709 valid = assertedType.valid;
1710 }
1711 }
1712
1713 if (!valid) {
1714 warn(
1715 getInvalidTypeMessage(name, value, expectedTypes),
1716 vm
1717 );
1718 return
1719 }
1720 var validator = prop.validator;
1721 if (validator) {
1722 if (!validator(value)) {
1723 warn(
1724 'Invalid prop: custom validator check failed for prop "' + name + '".',
1725 vm
1726 );
1727 }
1728 }
1729 }
1730
1731 var simpleCheckRE = /^(String|Number|Boolean|Function|Symbol)$/;
1732

Callers 1

validatePropFunction · 0.85

Calls 3

warnFunction · 0.70
assertTypeFunction · 0.70
getInvalidTypeMessageFunction · 0.70

Tested by

no test coverage detected