This only affects the zod schema. You can treat the select the same as the name in this example. Define the zod schema validation for the select to expect a non-empty string. By doing this you are accepting any string value from the select, expect for empty strings.
I do this because there is no way to return a JavaScript number from an input element. Please note, on 2:12 I explained that all inputs return a string in HTML, even the number input. You can verify this by checking the type of `event.target.value` when trying to read a value from an input.
@@techs7296 you can link everything to state object with onchange sync and then on submit verify the data, then you can get anything and bypass the string parsing... optimally regex, then you can completely remove zod and react hook form
Thanks a lot man. God bless you
i have two date values From and To, i want to validate those dates, such the To date value is not earlier than the From date, how to do so??
what if your select options would come from db, how your code would change?
This only affects the zod schema. You can treat the select the same as the name in this example. Define the zod schema validation for the select to expect a non-empty string. By doing this you are accepting any string value from the select, expect for empty strings.
Why form has weight as string defined, makes it difficult to post the data into the database.
I do this because there is no way to return a JavaScript number from an input element. Please note, on 2:12 I explained that all inputs return a string in HTML, even the number input. You can verify this by checking the type of `event.target.value` when trying to read a value from an input.
@@ramozdev I asked because I really want a proper solution. For now working by Using Number() .Open to any solution .
@@techs7296 you can link everything to state object with onchange sync and then on submit verify the data, then you can get anything and bypass the string parsing... optimally regex, then you can completely remove zod and react hook form