Skip to content
Closed
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
5 changes: 2 additions & 3 deletions docs/content/2.components/form.md
Original file line number Diff line number Diff line change
Expand Up @@ -63,11 +63,10 @@ Note that **no validation library is included** by default, so ensure you **inst

## Custom validation

Use the `validate` prop to apply your own validation logic.
Use the `validate` prop to apply your own validation logic. The validation function must return a list of errors with the following attributes:

The validation function must return a list of errors with the following attributes:
- `message` - Error message for display.
- `path` - Path to the form element corresponding to the `name` attribute.
- `path` - Path to the form element corresponding to the `name` attribute. To address multiple paths, join the path names with a period (`.`).

::callout{icon="i-heroicons-light-bulb"}
Note that it can be used alongside the `schema` prop to handle complex use cases.
Expand Down
2 changes: 1 addition & 1 deletion src/runtime/components/forms/FormGroup.vue
Original file line number Diff line number Diff line change
Expand Up @@ -111,7 +111,7 @@ export default defineComponent({
const error = computed(() => {
return (props.error && typeof props.error === 'string') || typeof props.error === 'boolean'
? props.error
: formErrors?.value?.find(error => error.path === props.name)?.message
: formErrors?.value?.find(error => error.path.split('.').includes(props.name))?.message
})

const size = computed(() => ui.value.size[props.size ?? config.default.size])
Expand Down