Optional, the default value is the value of the name property. In special cases, it is used to specify the path of the form data property corresponding to the field.
Value
Description
username
Corresponds to the username property of the form data attribute reference value, equivalent to data.username.
Validation rules for form items, which perform synchronous single-value validation. For the Array type, the item type is {triggers, name, message, value, validate, priority}.
Name
Type
Description
triggers
string
A collection of event names that trigger validation, separated by commas, supports <fieldName>:<eventName> to indicate that the validation is triggered when the fieldName field triggers the eventName event, refer to the example Inline Rule Validation.
name
string
Rule name.
value
*
The value that the rule should match. For boolean type rules, the default value is true.
message
string | function
Error message that can override the default rule error message.
If the type is string, {ruleValue} can be referenced with {ruleValue} and value can be referenced with {value}. For example:
let minLengthRule = {
validate (value, ruleValue) {
return !isEmpty(value) ? val.length >= ruleValue : true
},
message: 'The character length cannot be less than {ruleValue}, current length {value}',
priority: 100
}
If the type is function, the parameter is (ruleValue: ?*=, value: *). For example:
let minLengthRule = {
validate (value, ruleValue) {
return !isEmpty(value) ? val.length >= ruleValue : true
},
message (ruleValue, value) {
return`The character length cannot be less than ${ruleValue}, current length ${value}`
},
priority: 100
}
If you need to support multiple languages, message must use the function type.
priority
number
The priority of the rule, which can override the default priority.
validate
(value: unknown, ruleValue: unknown) => boolean
An inline validator used to directly write validation logic, refer to the example Inline Rule Validation.
Name
Type
Description
required
boolean
The value cannot be a null value (null / undefined / '' / []).
numeric
boolean
The value must be describable as a decimal number.(6 / 66.6 / 6e6 / '6' / .6)
pattern
RegExp | string
Regular expression matching.
maxLength
number
The value's length property cannot be greater than the limit.
minLength
number
The value's length property cannot be less than the limit.
max
number
The value cannot be greater than the limit.
min
number
The value cannot be less than the limit.
For string type, the format is rule1,rule2,..., and only supports rules with value type of boolean.
Priority affects the error message displayed at the end. The error message stack will retain all rule error messages, but only the highest priority one will be displayed.
When set to true, the input components (such as veui-input) in the content of this form item will not automatically bind validation events or enter the invalid state, and the user can customize it through the default slot.
Used by inline input components. Slot props include: (listeners: object, invalid: boolean, validities: object, readonly: boolean, disabled: boolean), where invalid indicates whether the current form item has failed validation, listeners are event bindings for validation, and validities are validation messages.