GitHub

NotArrayField

Renderless array wrapper with stable item keys and full mutation methods.

<NotArrayField> manages an array within your form values. It exposes items with stable keys for v-for, array state, and mutation methods through its default slot. Item keys survive reorders, inserts, and removals — elements are not re-mounted unnecessarily.

Props

PropTypeRequiredDescription
pathstringYesDot-separated path to the array within form.values.
itemSchemaStandardSchemaV1NoSchema for a single array item. Enables typed append, prepend, insert, and update in the slot. Not used for runtime validation.
validateOnPartial<Record<'onMount' | 'onChange', boolean>>NoTrigger overrides for this array. Only onMount and onChange are supported — onBlur, onFocus, and onInput are not meaningful at the array level.
formNotFormInstance<any>NoExplicit instance override. Required when used outside of <NotForm>.

Slot props — State

PropTypeDescription
pathstringThe dot-separated path passed to this array field.
itemsNotArrayFieldItem[]The current items. Each entry has a stable key, the current index, and the full path to pass to a nested <NotField>.
errorsStandardSchemaV1.Issue[]Validation issues targeting this array path specifically.
isValidbooleantrue when there are no errors for this array.
isTouchedbooleantrue if the array path itself or any item path has been touched.
isDirtybooleantrue if the array path itself or any item path is dirty.
isValidatingbooleantrue while validation is running for this array.
validate() => Promise<StandardSchemaV1.Result>Manually triggers validation for the array path.

Slot props — Mutation methods

MethodSignatureDescription
append(value: TItem) => voidAdds an item to the end of the array.
prepend(value: TItem) => voidAdds an item to the beginning of the array.
remove(index: number) => voidRemoves the item at the given index.
insert(index: number, value: TItem) => voidInserts an item at the given index. Subsequent items shift forward.
update(index: number, value: TItem) => voidReplaces the value at the given index. The item's stable key is preserved.
swap(indexA: number, indexB: number) => voidSwaps two items. Their stable keys move with them.
move(from: number, to: number) => voidMoves an item from one index to another. Items between the positions shift to fill the gap.

The NotArrayFieldItem type

PropertyTypeDescription
keystringStable — does not change on reorder.
indexnumberCurrent position in the array.
pathstringFull dot-separated path — pass directly to <NotField>.
Always use item.key on v-for and item.path as the path prop on nested <NotField> components.

Usage

String array

Typed items with itemSchema

Pass itemSchema to make append, prepend, insert, and update typed. Without it they accept any.

<script setup lang="ts">
const itemSchema = z.object({
  name: z.string().min(1),
  role: z.enum([
    'admin',
    'user',
  ]),
})

const form = useNotForm({
  initialValues: { members: [] },
  schema: z.object({ members: z.array(itemSchema) }),
})
</script>

<template>
  <NotForm
    :form="form"
    @submit="form.submit"
  >
    <NotArrayField
      v-slot="{ items, append, remove }"
      path="members"
      :item-schema="itemSchema"
    >
      <!-- TypeScript knows the shape: { name: string; role: 'admin' | 'user' } -->
      <button
        type="button"
        @click="append({ name: '', role: 'user' })"
      >
        Add member
      </button>
    </NotArrayField>
  </NotForm>
</template>

Array-level errors

Issues targeting the array path itself (e.g., minimum length rules) are in errors, separate from individual item errors.

<template>
  <NotArrayField
    v-slot="{ path }"
    path="tags"
  >
    <!-- items -->
    <NotMessage :path="path" />
  </NotArrayField>
</template>