Skip to content

feat(pages): add useForm setError and clear field errors on change - #4

Draft
0froq wants to merge 1 commit into
mainfrom
cursor/feat-useform-seterror-dbee
Draft

0froq wants to merge 1 commit into
mainfrom
cursor/feat-useform-seterror-dbee

Conversation

@0froq

@0froq 0froq commented Oct 25, 2026

Copy link
Copy Markdown
Owner

Fixes voidzero-dev#525

Summary

Adds setError(field, message) to useForm across React, Vue, Svelte, and Solid so apps can surface client-side validation through the same typed errors object as server withValidator() responses.

Changing a field clears that field's validation error automatically:

  • React and Solid: setData(field, value) clears errors[field]
  • Vue and Svelte: assigning to data clears errors[field] (snapshot-based watch / $effect)

API

Method Purpose
setError(field, message) Set a client-side field validation error
(existing) clearErrors(...fields) Clear validation errors manually

Tests

  • packages/vue/test/unit/use-form.test.ts — setError and clearing on data change

Typecheck

@void/react, @void/vue, @void/svelte, @void/solid

Fit to voidzero-dev#525

Implements proposal (1) setError(field, message) and proposal (2) clear-on-change via setData / data assignment, unblocking client-side schema validation in userland without a second error state.

Related: voidzero-dev#523 (form line; reset behavior is separate in PR voidzero-dev#568 on upstream).

Open in Web Open in Cursor 

Fixes voidzero-dev#525

## Summary

Adds `setError(field, message)` to `useForm` across React, Vue, Svelte, and Solid so apps can surface client-side validation through the same typed `errors` object as server `withValidator()` responses.

Changing a field clears that field's validation error automatically:
- React and Solid: `setData(field, value)` clears `errors[field]`
- Vue and Svelte: assigning to `data` clears `errors[field]` (snapshot-based watch / $effect)

## API

| Method | Purpose |
| --- | --- |
| `setError(field, message)` | Set a client-side field validation error |
| (existing) `clearErrors(...fields)` | Clear validation errors manually |

## Tests

- `packages/vue/test/unit/use-form.test.ts` — `setError` and clearing on `data` change

## Docs

- `docs/guide/pages-routing/actions-and-forms.md`
- `docs/reference/api/pages.md`

## Typecheck

`@void/react`, `@void/vue`, `@void/svelte`, `@void/solid`

## Fit to voidzero-dev#525

Implements proposal (1) `setError(field, message)` and proposal (2) clear-on-change via `setData` / `data` assignment, unblocking client-side schema validation in userland without a second error state.

Co-authored-by: froQ <sayhola@froq.me>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

useForm: support client-side validation (or at least setError)

2 participants