Home / Function/ assertProp() — vue Function Reference

assertProp() — vue Function Reference

Architecture documentation for the assertProp() function in props.ts from the vue codebase.

Function typescript VueCore Observer calls 3 called by 1

Entity Profile

Dependency Diagram

graph TD
  bdff343d_a655_05a3_a87d_d14305aacd8d["assertProp()"]
  ebb0510e_1beb_0f1e_d9b5_9f9e319cefcc["props.ts"]
  bdff343d_a655_05a3_a87d_d14305aacd8d -->|defined in| ebb0510e_1beb_0f1e_d9b5_9f9e319cefcc
  7425417e_e38e_e5e8_6678_47ee9b0e04c2["validateProp()"]
  7425417e_e38e_e5e8_6678_47ee9b0e04c2 -->|calls| bdff343d_a655_05a3_a87d_d14305aacd8d
  48bc61b1_05ca_3121_50a7_2f02cdcf2f03["warn()"]
  bdff343d_a655_05a3_a87d_d14305aacd8d -->|calls| 48bc61b1_05ca_3121_50a7_2f02cdcf2f03
  14d92bc1_ead1_09a4_f147_3d6283934bf2["assertType()"]
  bdff343d_a655_05a3_a87d_d14305aacd8d -->|calls| 14d92bc1_ead1_09a4_f147_3d6283934bf2
  2b816e9d_8877_5f48_8b92_704ec73eda9e["getInvalidTypeMessage()"]
  bdff343d_a655_05a3_a87d_d14305aacd8d -->|calls| 2b816e9d_8877_5f48_8b92_704ec73eda9e
  style bdff343d_a655_05a3_a87d_d14305aacd8d fill:#6366f1,stroke:#818cf8,color:#fff

Relationship Graph

Source Code

src/core/util/props.ts lines 105–147

function assertProp(
  prop: PropOptions,
  name: string,
  value: any,
  vm?: Component,
  absent?: boolean
) {
  if (prop.required && absent) {
    warn('Missing required prop: "' + name + '"', vm)
    return
  }
  if (value == null && !prop.required) {
    return
  }
  let type = prop.type
  let valid = !type || (type as any) === true
  const expectedTypes: string[] = []
  if (type) {
    if (!isArray(type)) {
      type = [type]
    }
    for (let i = 0; i < type.length && !valid; i++) {
      const assertedType = assertType(value, type[i], vm)
      expectedTypes.push(assertedType.expectedType || '')
      valid = assertedType.valid
    }
  }

  const haveExpectedTypes = expectedTypes.some(t => t)
  if (!valid && haveExpectedTypes) {
    warn(getInvalidTypeMessage(name, value, expectedTypes), vm)
    return
  }
  const validator = prop.validator
  if (validator) {
    if (!validator(value)) {
      warn(
        'Invalid prop: custom validator check failed for prop "' + name + '".',
        vm
      )
    }
  }
}

Domain

Subdomains

Called By

Frequently Asked Questions

What does assertProp() do?
assertProp() is a function in the vue codebase, defined in src/core/util/props.ts.
Where is assertProp() defined?
assertProp() is defined in src/core/util/props.ts at line 105.
What does assertProp() call?
assertProp() calls 3 function(s): assertType, getInvalidTypeMessage, warn.
What calls assertProp()?
assertProp() is called by 1 function(s): validateProp.

Analyze Your Own Codebase

Get architecture documentation, dependency graphs, and domain analysis for your codebase in minutes.

Try Supermodel Free