You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
And then I'm using a <PhoneInput /> element from react-phone-number-input to collect the number.
For the CSV upload, I am passing the value as text to a tRPC mutation because tRPC doesn't handle multipart/form-data requests. (Maybe this is the problem?)
// router.tsconstt=initTRPC.context<Context>().create({transformer: superjson,});
...
exportconstappRouter=t.router({uploadVoterNeeds: protectedProcedure.input(z.string()).mutation(async(opts)=>{const{ input }=opts;constx=parseCsv(input);returnnull;// obviously I'm going to do more here, but I haven't gotten that far yet because of this bug}),
...
})
Tried to be as exhaustive as I could here, but omitted some things for brevity, lmk if you need clarification on anything.
With this setup, when I pass a valid US phone number (a real phone number taken from my contacts) via the form, the validation passes. When I pass that same phone number in a CSV, validation fails. Anyone got any ideas for me? the LLMs have failed me, and I can't really figure out how to debug further. My best guess is that it has something to do with how I'm passing data to the tRPC route, but I can't rule out that it's an issue with the validator function itself, so I'm posting here.
I did try manually testing one of the records in parseCsv to confirm that the check really is returning false, and it is:
consttestPhone=parsed[0].phone;console.log(`Phone number ${testPhone} valid: ${isValidPhoneNumber(testPhone)}`,// returns false);
Note: I was originally importing isValidPhoneNumber from "react-phone-number-input", but since that package just exports that function from this one, I'm posting here. I changed the import (as you can see above) and confirmed the same behavior.
The text was updated successfully, but these errors were encountered:
Hi. I can see that you've described your issue in much detail but that's also a "cons" because I personally won't bother reading though that. The bottom line in general is: library maintainers can only look at minimal reproducible sandboxes, and that usually means plain javascript + the library as the only included dependency.
Hi. I can see that you've described your issue in much detail but that's also a "cons" because I personally won't bother reading though that. The bottom line in general is: library maintainers can only look at minimal reproducible sandboxes, and that usually means plain javascript + the library as the only included dependency.
A bug so bizarre that it must be because I'm doing something simple wrong, but here goes:
I have a full stack react app in which phone numbers can be added to a database using a form or via CSV upload. Here's my validation schema:
On the frontend, I've got a
react-hook-form
using the schema:And then I'm using a
<PhoneInput />
element from react-phone-number-input to collect the number.For the CSV upload, I am passing the value as text to a tRPC mutation because tRPC doesn't handle multipart/form-data requests. (Maybe this is the problem?)
Tried to be as exhaustive as I could here, but omitted some things for brevity, lmk if you need clarification on anything.
With this setup, when I pass a valid US phone number (a real phone number taken from my contacts) via the form, the validation passes. When I pass that same phone number in a CSV, validation fails. Anyone got any ideas for me? the LLMs have failed me, and I can't really figure out how to debug further. My best guess is that it has something to do with how I'm passing data to the tRPC route, but I can't rule out that it's an issue with the validator function itself, so I'm posting here.
I did try manually testing one of the
records
inparseCsv
to confirm that the check really is returning false, and it is:Note: I was originally importing
isValidPhoneNumber
from"react-phone-number-input"
, but since that package just exports that function from this one, I'm posting here. I changed the import (as you can see above) and confirmed the same behavior.The text was updated successfully, but these errors were encountered: