TanStack / form

🤖 Powerful and type-safe form state management for the web. TS/JS, React Form, Solid Form, Lit Form and Vue Form.
https://tanstack.com/form
MIT License
3.74k stars 338 forks source link

Add an API to set errors #786

Closed crutchcorn closed 2 months ago

crutchcorn commented 4 months ago
field.setErrorMap();

We cannot provide a setErrors API as it derives that state from the errorMap

And:

form.resetErrors();

I'm less certain about this API. Why do we need it? CC @samuelthng

Toavina23 commented 3 months ago

hello @crutchcorn

I would like to work on this issue. Is there any advice or guide that you can give the correctly implement this feature ?

crutchcorn commented 3 months ago

Hey @Toavina23 the idea is that you'll add it to:

https://github.com/TanStack/form/blob/main/packages/form-core/src/FormApi.ts

https://github.com/TanStack/form/blob/main/packages/form-core/src/FieldApi.ts

field.setErrorMap() should update the field's meta errorMap property

Balastrong commented 2 months ago

Done in #821