Skip to content

docs: use componentField in vee-validate examples - #1909

Merged
zernonia merged 2 commits into
devfrom
vee-validate-componentField-slotProp
Aug 7, 2026
Merged

docs: use componentField in vee-validate examples#1909
zernonia merged 2 commits into
devfrom
vee-validate-componentField-slotProp

Conversation

@sadeghbarati

@sadeghbarati sadeghbarati commented Jul 31, 2026

Copy link
Copy Markdown
Collaborator

🔗 Linked issue

Close #1638
Close #1640

❓ Type of change

  • 📖 Documentation (updates to the documentation, readme or JSdoc annotations)
  • 🐞 Bug fix (a non-breaking change that fixes an issue)
  • 👌 Enhancement (improving an existing functionality like performance)
  • ✨ New feature (a non-breaking change that adds functionality)
  • 🧹 Chore (updates to the build process or auxiliary tools and libraries)
  • ⚠️ Breaking change (fix or feature that would cause existing functionality to change)

📚 Description

Clarify the vee-validate usage for Vue form components

📸 Screenshots (if appropriate)

📝 Checklist

  • I have linked an issue or discussion.
  • I have updated the documentation accordingly.

Summary by CodeRabbit

  • New Features

    • Updated form demos with clearer validation feedback, field descriptions, error messages, and invalid-state accessibility attributes.
    • Improved checkbox, select, radio, switch, textarea, password, and array-field interactions across validation examples.
    • Enhanced multi-step form validation and field identification.
  • Documentation

    • Clarified when to use component bindings versus native field bindings.
    • Added guidance and examples for boolean checkboxes and checkbox arrays.

@coderabbitai

coderabbitai Bot commented Jul 31, 2026

Copy link
Copy Markdown
Contributor

Review Change Stack

📝 Walkthrough

Walkthrough

The PR migrates VeeValidate demos and documentation to use componentField for Vue components. It also updates native select and stepper demos to use shared field components with validation and accessibility state.

Changes

VeeValidate migration

Layer / File(s) Summary
Form demo field migration
apps/v4/components/demo/NativeSelectFormDemo.vue, apps/v4/components/demo/StepperForm.vue
The demos use VeeForm, VeeField, shared field components, explicit IDs, validation errors, and invalid-state attributes.
Component binding migration
apps/v4/components/demo/VeeValidate*Demo.vue
Vue components use componentField. Checkbox arrays use value and handleChange to update selected values.
VeeValidate documentation updates
apps/v4/content/docs/forms/01.vee-validate.md
The documentation distinguishes componentField from field and updates input, select, checkbox, radio, switch, and array examples.

Estimated code review effort: 3 (Moderate) | ~20 minutes

Possibly related PRs

Suggested reviewers: zernonia

🚥 Pre-merge checks | ✅ 5
✅ Passed checks (5 passed)
Check name Status Explanation
Description Check ✅ Passed Check skipped - CodeRabbit’s high-level summary is enabled.
Title check ✅ Passed The title clearly summarizes the main change: using componentField in vee-validate examples.
Linked Issues check ✅ Passed The changes recommend componentField and migrate the relevant examples from Form and legacy form components to Field [#1638] [#1640].
Out of Scope Changes check ✅ Passed The changes remain within the linked documentation objectives, including related example, accessibility, and API usage corrections.
Docstring Coverage ✅ Passed No functions found in the changed files to evaluate docstring coverage. Skipping docstring coverage check.
✨ Finishing Touches
🧪 Generate unit tests (beta)
  • Create PR with unit tests
  • Commit unit tests in branch vee-validate-componentField-slotProp

Thanks for using CodeRabbit! It's free for OSS, and your support helps us grow. If you like it, consider giving us a shout-out.

❤️ Share

Comment @coderabbitai help to get the list of available commands.

@sadeghbarati
sadeghbarati requested a review from zernonia July 31, 2026 20:48
@zernonia
zernonia force-pushed the vee-validate-componentField-slotProp branch from c9a2d88 to 55bd997 Compare August 1, 2026 09:07
@zernonia
zernonia force-pushed the vee-validate-componentField-slotProp branch from 55bd997 to 28c5409 Compare August 5, 2026 09:06
@sadeghbarati
sadeghbarati force-pushed the vee-validate-componentField-slotProp branch from 28c5409 to 32668a2 Compare August 5, 2026 14:13
Base automatically changed from feat/reka-ui-drawer to dev August 7, 2026 06:19
sadeghbarati and others added 2 commits August 7, 2026 14:22
shadcn-vue form controls are Vue components with a modelValue prop bound
internally via v-model. Binding `field` passes `value`, which falls through
as a plain attribute and is overwritten by the component's own v-model, so
initialValues never render. Typing still works, which hid the bug.

Switch Input, Textarea, InputGroupInput, InputGroupTextarea, Select,
Checkbox, RadioGroup and Switch to `v-bind="componentField"`. Checkbox
arrays keep manual binding via the `value` and `handleChange` slot props,
since one field owns the whole array.

Also:
- Add Component/Native tabs to Anatomy showing when each slot prop applies
- Fix invalid `(checked | 'indeterminate')` handler signature
- Add missing `type="checkbox"` to the Switch example
- Move `:aria-invalid` from RadioGroupItem to RadioGroup
- Drop `@blur` from Select; SelectRoot sets inheritAttrs: false and discards it
- Realign stale showLineNumbers ranges

Co-Authored-By: Claude Opus 5 <noreply@anthropic.com>
@zernonia
zernonia force-pushed the vee-validate-componentField-slotProp branch from 32668a2 to 68734a7 Compare August 7, 2026 06:26

@coderabbitai coderabbitai Bot left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Actionable comments posted: 1

🤖 Prompt for all review comments with AI agents
Verify each finding against current code. Fix only still-valid issues, skip the
rest with a brief reason, keep changes minimal, and validate.

Inline comments:
In `@apps/v4/components/demo/StepperForm.vue`:
- Around line 75-78: Update the VeeForm submit handler to be asynchronous and
await validate() before deciding whether to submit; use the returned valid value
rather than the potentially stale meta.valid, especially for the final step.
Preserve the existing submission flow for valid forms.
🪄 Autofix

Fix all unresolved CodeRabbit comments on this PR:

  • Push a commit to this branch (recommended)
  • Create a new PR with the fixes

ℹ️ Review info
⚙️ Run configuration

Configuration used: defaults

Review profile: CHILL

Plan: Pro Plus

Run ID: 4414aa8f-9b5a-49fa-b7b3-14d419a59e44

📥 Commits

Reviewing files that changed from the base of the PR and between cc9f4ec and 68734a7.

📒 Files selected for processing (13)
  • apps/v4/components/demo/NativeSelectFormDemo.vue
  • apps/v4/components/demo/StepperForm.vue
  • apps/v4/components/demo/VeeValidateArrayDemo.vue
  • apps/v4/components/demo/VeeValidateCheckboxDemo.vue
  • apps/v4/components/demo/VeeValidateComplexDemo.vue
  • apps/v4/components/demo/VeeValidateDemo.vue
  • apps/v4/components/demo/VeeValidateInputDemo.vue
  • apps/v4/components/demo/VeeValidatePasswordDemo.vue
  • apps/v4/components/demo/VeeValidateRadioGroupDemo.vue
  • apps/v4/components/demo/VeeValidateSelectDemo.vue
  • apps/v4/components/demo/VeeValidateSwitchDemo.vue
  • apps/v4/components/demo/VeeValidateTextareaDemo.vue
  • apps/v4/content/docs/forms/01.vee-validate.md

Comment on lines +75 to 78
<VeeForm
v-slot="{ meta, values, validate }"
as="" keep-values :validation-schema="toTypedSchema(formSchema[stepIndex - 1]!)"
>

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

🎯 Functional Correctness | 🟠 Major | ⚡ Quick win

🧩 Analysis chain

🏁 Script executed:

#!/usr/bin/env bash
set -euo pipefail

# Inspect the installed dependency declaration and comparable validation flows.
fd -a 'package.json' . -E node_modules -E dist
rg -n -C 4 '"vee-validate"' --glob 'package.json'
rg -n -C 5 'validate\(\).*meta\.valid|await validate\(\)' apps/v4 --glob '*.vue'

Repository: unovue/shadcn-vue

Length of output: 2008


🏁 Script executed:

#!/usr/bin/env bash
set -uo pipefail

echo "== package declarations =="
for f in package.json apps/v4/package.json; do
  if [ -f "$f" ]; then
    echo "--- $f ---"
    jq '.dependencies, .devDependencies' "$f" 2>/dev/null | rg -n -C 2 'vee-validate' || true
  fi
done

echo "== locate StepperForm.vue =="
fd -a 'StepperForm.vue' . -E node_modules -E dist

echo "== StepperForm outline and relevant section =="
file="$(fd 'StepperForm.vue' . -E node_modules -E dist | head -n 1)"
if [ -n "${file:-}" ]; then
  echo "FILE=$file"
  wc -l "$file"
  sed -n '1,180p' "$file" | cat -n
fi

echo "== vee-validate usages in apps/v4 =="
rg -n -C 4 'validate\(|meta\.valid|VeeForm|toTypedSchema' apps/v4 --glob '*.vue' --glob '*.ts' --glob '*.js' || true

Repository: unovue/shadcn-vue

Length of output: 50373


🌐 Web query:

VueUse vee-validate toTypedSchema VeeForm validate function returns Promise valid meta.valid documentation

💡 Result:

In vee-validate, the validate function provided by useForm returns a Promise that resolves to an object containing the aggregated validation result of all fields [1]. Specifically, this object has the structure { valid: boolean, errors: Record<string, string> } [1]. Regarding meta.valid: - The meta.valid property is part of the form's metadata (accessible via useForm) and indicates the overall validity of the form [2][3]. - It is determined by whether the errors object is empty [2][3]. - Please note that meta.valid may be initially true (as it simply means no errors have been recorded yet) before the first validation run occurs [2][3]. For accurate UI states, it is often recommended to combine meta.valid with other flags like meta.dirty or meta.touched [2][3]. The toTypedSchema function is a utility provided by @vee-validate/yup or @vee-validate/zod (depending on your validation library) that transforms your validation schema into a format compatible with vee-validate [4][5][6]. It enables automatic type inference for your form values and ensures the schema is correctly interpreted by the validate function during form-level or field-level validation [4][5][7].

Citations:


Await step validation before submitting.

validate() validates async, but this handler checks meta.valid immediately. On the final step, an invalid final step can submit if meta.valid still reflects the previous step. Make the submit callback async, await validate(), and use the returned { valid }.

🤖 Prompt for AI Agents
Verify each finding against current code. Fix only still-valid issues, skip the
rest with a brief reason, keep changes minimal, and validate.

In `@apps/v4/components/demo/StepperForm.vue` around lines 75 - 78, Update the
VeeForm submit handler to be asynchronous and await validate() before deciding
whether to submit; use the returned valid value rather than the potentially
stale meta.valid, especially for the final step. Preserve the existing
submission flow for valid forms.

@zernonia
zernonia merged commit 43209b4 into dev Aug 7, 2026
5 checks passed
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

2 participants