I'm having trouble coming up with a name for this concept, so I don't know what specific term to search for. I've checked out some directives, but I'm not convinced that's what I need. Essentially, I want to be able to do the following:
v-on:click.validate="runCode"
Here, validate
is a custom method that will execute before calling runCode
, similar to how .prevent
functions.
Could anyone direct me to some documentation or provide an example?
Additional details: I have developed customized form components that send validation data to my state. These form components can be used as needed, like so:
<msp-input
v-model="form.username"
:validation="{ required, email }"
float-label="Email Address"
type="email"
/>
I would like to incorporate a button on any of the forms that triggers a validation alert if the state indicates a validation failure. While I could create an <msp-button>
component for this purpose, I thought it would be more convenient to have an inline .validate
option available.