brillout / telefunc

Remote Functions. Instead of API.
https://telefunc.com
MIT License
688 stars 31 forks source link

What about more complex types such as email or password? #84

Closed 205g0 closed 1 year ago

205g0 commented 1 year ago

The beauty of telefunc is the auto type validation but I can't express an email or password type well in TS. Both can be checked in the client via HTML Input types but we'd need to check them on the server as well. We could do this manually or employ another val lib like zod but then we'd need to build another infrastructure for the second validation lib, its error handing, etc. Then, why do we have telefunc's auto val in the first place?

And even if we built the second val infrastructure, we'd need to double the zod def or val contract and the RPC function signature/parameters. We could infer from the zod type but would end up with additional boilerplate and/or ruin the simple telefunc api.

I currently use zod, where you have turn-key types for email or can easily set that the password has a min length and so on. TS still lacks and will for some time regex types, check also https://github.com/microsoft/TypeScript/issues/41160#issuecomment-1503653578 so I wonder, how telefunc should work IRL without these types.

I really want to use telefunc and hope I miss something...

brillout commented 1 year ago

Duplicate of https://github.com/brillout/telefunc/issues/42.

As for error handling, I don't see any added value compared to the solution suggested at https://telefunc.com/form-validation.