Hacktoberfest 2026: as issues que os mantenedores marcaram para outubro, abertas e boas para iniciantes. Ver issues do Hacktoberfest

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

Aberta
#525 0 comentários 0 reações 0 responsáveis Ver no GitHub

Mantenedores costumam responder em até 1 dia

Ninguém assumiu esta issue ainda.

Avaliação

Dificuldade
3/5
Tempo estimado
1-2 dias
Facilidade para iniciantes
54/100
Tipo de issue
Funcionalidade
Clareza
Razoavelmente clara
Status de atividade
Ativa
Stack de tecnologia
typescript
Domínio
frontend

Direção de pesquisa

Start by locating the useForm implementation and its tests in the @void/react package; the issue does not name specific files. Trace how errors, clearErrors, and setData are handled, then check how server validation maps errors into the form. Done means the chosen proposal works through form.errors and has tests for setting errors and, if implemented, clearing them on change.

Escrita pelo modelo de indexação a partir do texto da issue.

Descrição

Version

void / @void/react 1.1.12

Problem

useForm only fills errors from the server's withValidator() response. There's no way to validate in the browser and show errors through the same errors object:

  • there's no setError / setErrors, only clearErrors,
  • the Zod schema already used in withValidator() can be run on the client by hand, but its results can't be wired into form.errors,
  • errors don't clear when a field changes, so each onChange needs its own clearErrors(field) call.

As a result, apps that want inline validation as the user types either keep a second error state next to form.errors, or switch to another form library and lose useForm's typed action URL, pending and server error mapping.

Proposal

Any of these, from smallest to largest:

  1. setError(field, message): lets apps run their own validation and show the result through form.errors.
  2. An option to clear a field's error on change, e.g. clearErrorsOnChange: true, so setData(field, …) also clears errors[field].
  3. Optional client-side validation with the action's schema, e.g. useForm(url, defaults, { validate: createNoteSchema, validateOn: 'blur' | 'change' }). That would give the same messages in the browser and on the server, from one schema.

(1) and (2) are small and unblock building (3) in userland.

Related: #523, #524

Linguagem predominante
TypeScript
Estrelas
402
Forks
32
Merge médio
10h 18min
PRs com merge (30d)
113

Preparar o ambiente

Este projeto não oferece contêiner de desenvolvimento, Dockerfile nem guia de contribuição, então a configuração fica por sua conta: comece pelo README e veja nosso guia da primeira contribuição para os passos gerais.

Primeiros passos

  1. Leia a issue inteira e depois o guia de contribuição do projeto.
  2. Comente na issue dizendo que vai assumir — evita que duas pessoas façam o mesmo trabalho.
  3. Faça um fork do repositório e trabalhe em uma branch.
  4. Abra um pull request que referencie o número da issue.

Mais de voidzero-dev/void

Todas as issues de voidzero-dev/void

Issues semelhantes

Mais issues de TypeScript

Receba novas issues na sua caixa de entrada

Um resumo curto de issues do GitHub para quem está começando.