Home / Function/ validateProp() — vue Function Reference

validateProp() — vue Function Reference

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

Entity Profile

Dependency Diagram

graph TD
  50f52114_04b8_bc98_a41e_bc26a88ea2ab["validateProp()"]
  48552ac3_589d_0990_1979_1bd455665b33["hasOwn()"]
  50f52114_04b8_bc98_a41e_bc26a88ea2ab -->|calls| 48552ac3_589d_0990_1979_1bd455665b33
  4b5ff4c4_4a84_fe92_52cb_28a8c9c68200["getTypeIndex()"]
  50f52114_04b8_bc98_a41e_bc26a88ea2ab -->|calls| 4b5ff4c4_4a84_fe92_52cb_28a8c9c68200
  e667d00b_a47f_c88a_e931_82b5917dddc2["hyphenate()"]
  50f52114_04b8_bc98_a41e_bc26a88ea2ab -->|calls| e667d00b_a47f_c88a_e931_82b5917dddc2
  d405b246_79c5_0fda_f20d_75ebd8bfe36b["getPropDefaultValue()"]
  50f52114_04b8_bc98_a41e_bc26a88ea2ab -->|calls| d405b246_79c5_0fda_f20d_75ebd8bfe36b
  65e1e423_bb6b_4902_ff2a_5a19cc670a5f["toggleObserving()"]
  50f52114_04b8_bc98_a41e_bc26a88ea2ab -->|calls| 65e1e423_bb6b_4902_ff2a_5a19cc670a5f
  8d0e2195_5d6b_3567_6ef9_1a9c6d6caf20["observe()"]
  50f52114_04b8_bc98_a41e_bc26a88ea2ab -->|calls| 8d0e2195_5d6b_3567_6ef9_1a9c6d6caf20
  dcde110b_8854_c944_bfb4_3d5581f6359e["assertProp()"]
  50f52114_04b8_bc98_a41e_bc26a88ea2ab -->|calls| dcde110b_8854_c944_bfb4_3d5581f6359e
  style 50f52114_04b8_bc98_a41e_bc26a88ea2ab fill:#6366f1,stroke:#818cf8,color:#fff

Relationship Graph

Source Code

src/core/util/props.ts lines 22–59

export function validateProp(
  key: string,
  propOptions: Object,
  propsData: Object,
  vm?: Component
): any {
  const prop = propOptions[key]
  const absent = !hasOwn(propsData, key)
  let value = propsData[key]
  // boolean casting
  const booleanIndex = getTypeIndex(Boolean, prop.type)
  if (booleanIndex > -1) {
    if (absent && !hasOwn(prop, 'default')) {
      value = false
    } else if (value === '' || value === hyphenate(key)) {
      // only cast empty string / same name to boolean if
      // boolean has higher priority
      const stringIndex = getTypeIndex(String, prop.type)
      if (stringIndex < 0 || booleanIndex < stringIndex) {
        value = true
      }
    }
  }
  // check default value
  if (value === undefined) {
    value = getPropDefaultValue(vm, prop, key)
    // since the default value is a fresh copy,
    // make sure to observe it.
    const prevShouldObserve = shouldObserve
    toggleObserving(true)
    observe(value)
    toggleObserving(prevShouldObserve)
  }
  if (__DEV__) {
    assertProp(prop, key, value, vm, absent)
  }
  return value
}

Domain

Subdomains

Frequently Asked Questions

What does validateProp() do?
validateProp() is a function in the vue codebase.
What does validateProp() call?
validateProp() calls 7 function(s): assertProp, getPropDefaultValue, getTypeIndex, hasOwn, hyphenate, observe, toggleObserving.

Analyze Your Own Codebase

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

Try Supermodel Free