validateProp() — vue Function Reference
Architecture documentation for the validateProp() function in props.ts from the vue codebase.
Entity Profile
Dependency Diagram
graph TD b943403b_6390_a1db_4eec_d4fea1238518["validateProp()"] e8576a88_2e85_86ff_b2f9_bbbb6de70a51["props.ts"] b943403b_6390_a1db_4eec_d4fea1238518 -->|defined in| e8576a88_2e85_86ff_b2f9_bbbb6de70a51 4f9bc8a7_c807_b563_6f3f_f5d992f87a77["getTypeIndex()"] b943403b_6390_a1db_4eec_d4fea1238518 -->|calls| 4f9bc8a7_c807_b563_6f3f_f5d992f87a77 a06153e2_673f_da2d_1fcd_fd4c7ab29577["getPropDefaultValue()"] b943403b_6390_a1db_4eec_d4fea1238518 -->|calls| a06153e2_673f_da2d_1fcd_fd4c7ab29577 2bcc88b5_db8a_b047_2abd_7382948898ab["toggleObserving()"] b943403b_6390_a1db_4eec_d4fea1238518 -->|calls| 2bcc88b5_db8a_b047_2abd_7382948898ab c50e49cd_c223_e73e_c96d_1c8391fde3c1["observe()"] b943403b_6390_a1db_4eec_d4fea1238518 -->|calls| c50e49cd_c223_e73e_c96d_1c8391fde3c1 d12d8448_7216_80ce_8a3d_b515beeca7cf["assertProp()"] b943403b_6390_a1db_4eec_d4fea1238518 -->|calls| d12d8448_7216_80ce_8a3d_b515beeca7cf style b943403b_6390_a1db_4eec_d4fea1238518 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
Defined In
Source
Frequently Asked Questions
What does validateProp() do?
validateProp() is a function in the vue codebase, defined in src/core/util/props.ts.
Where is validateProp() defined?
validateProp() is defined in src/core/util/props.ts at line 22.
What does validateProp() call?
validateProp() calls 5 function(s): assertProp, getPropDefaultValue, getTypeIndex, observe, toggleObserving.
Analyze Your Own Codebase
Get architecture documentation, dependency graphs, and domain analysis for your codebase in minutes.
Try Supermodel Free