react-query-questions
solid-query-questions
table-questions
virtual-questions
router-questions
react-charts-questions
ranger-questions
vue-query-questions
svelte-query-questions
bling-questions
form-questions
angular-query-questions
start-questions
db-questions
start-showcase
router-showcase
📣-announcements
Best practice typing a boolean field using zod (or other schema library)
isDogOwner: z.boolean()
Now, if I don't provide a default value in my defaultValues, typescript will complain that it's not matching the schema.
If I make it optional in zod, it will be optional in defaultValues.. but now my form validation is not right since I need the user to make a choice before submitting....Type hints when declaring formComponent / fieldComponent
fieldComponent
/ formComponent
so that it is aware of the form / field it is used from?
For example a Textfield
component that error out if the field it is used in is not of type string
Or an example I did recently: I wanted a generic ArrayField
that displays a consistent field for array fields in form. I did it like this (look into message below)
but it would be really nice to be able to not tie it to current form (in here FormData
) but make it generic, preserving type safety for name
prop...Different schema for form and output
Incorrect type for field.state.meta.errors?
field.state.meta.errors
is undefined when the Typescript type argues it is always an array. I have a simple form with two fields which are validated with zod.
```ts
const productSchema = z.object({
name: z.string().min(1, "A name is required"),
allowance: z...[Solid] Performance issue with large form?
How to reset the value of an object field in an array
``ts
<td>
<form.Field
name={
lines[${i}].building_product_group`}...How to access to the validation schema inside a FieldComponent?

withForm-TypeError-fix
How to properly output error from useForm onSubmit
Form-getFieldValue-Alternative
Form composition create reusable component using withForm
Epic stack using tanstack form instead of conform
Ways to create sub-form to be used as form array
ItemForm
here
```tsx
export const ItemForm = withForm({
defaultValues: {} as z.infer<typeof itemSchema>,
validators: {...
Form composition
Form-SubmitButton-UseStore
When is the schema validation ACTUALLY happening?
REFINED VALUE
is of type number
). However, when I log the the value and its type in onSubmit
handler, it is a string
.
Isn't this weird? In zod, when I run values through a schema, I can count on them being the correct type, but here it seems it doesn't work that way. It seems like the result of the parsing is thrown away and the original values are returned in the onSubmit
handler. Is this a bug or a required behavior?...Optional fields
Need to re-visit unmounted fields in order for the validators to update the errors
canSubmitWhenInvalid
, but I'm getting a pretty inconsistent behaviour if some of the fields are not mounted on the DOM....Form state is inconsistent when using with server action