Question presented to candidate:
"Our age field stores "42" as a string, the username keeps stray spaces, and a search box fires an API call on every keystroke. Which v-model modifiers would you reach for, what exactly does each one do, and can a component define its own?"
What a strong answer should cover:
.lazysyncs on thechangeevent (blur or Enter) instead of everyinputevent..numberconverts withparseFloat, and keeps the original string when it cannot parse ("abc"stays"abc");type="number"inputs get this automatically..trimstrips leading and trailing whitespace from the stored value.- Modifiers chain:
v-model.lazy.number. - On components, modifiers arrive as a
modelModifiersprop (or<name>Modifiersfor named models); custom ones are implemented withdefineModel'ssettransformer. Built-in.trimand.numberare applied for you. - Modifiers are a convenience for timing and type coercion, not validation.
Clarifying questions expected:
- "Should an empty or invalid number be stored as a string,
null, or rejected?"
Code / implementation expected: Yes. A form showing the three built-in modifiers; bonus for a custom modifier on a component.