Validation
There are two ways to pass rules:
a. Through the form's validation
prop.
b. Through the rules
prop of each individual field.
Rules which depend on other fields (i.e requiredIf
,greaterThan
and smallerThan
) should be passed using option a
.
Option a
example:
{
rules: {
username: {
required:true,
min: 6
},
password: {
required:true
}
},
messages:{
username: {
required:"custom message for :field"
}
}
}
The optional messages
property overrides the default messages object for a specific field.
Option b
example:
<vf-text label="Username:" name="username" :rules="{required:true, min:6}"></vf-text>
The required
rule can also be passed as a prop. E.g:
<vf-text label="Username:" name="username" required></vf-text>