in_array
| Category | Cross-field |
| Related | in · distinct |
| Bundle size | 242 B |
Validates that the value exists in another element's array value.
Usage
vue
<VfCheckboxes
name="options"
label="Options"
:items="['Red', 'Green', 'Blue']"
/>
<VfText name="favorite" label="Favorite" rules="in_array:options" />vue
<template>
<VfCheckboxes
name="options"
label="Options"
:items="['Red', 'Green', 'Blue']"
/>
<VfText name="favorite" label="Favorite" rules="in_array:options" />
</template>ts
{
options: {
type: 'checkboxes',
label: 'Options',
items: ['Red', 'Green', 'Blue'],
},
favorite: {
type: 'text',
label: 'Favorite',
rules: 'in_array:options',
},
}Parameters
| Parameter | Description |
|---|---|
other | The path of the element to compare against — see Referencing Other Elements. |
Behavior
A trailing .* wildcard on the referenced path is accepted and stripped — in_array:options.* is equivalent to in_array:options.
Error Messages
| Key | Default Message |
|---|---|
rule_in_array_error | The {attribute} field does not exist in {other}. |