-
Notifications
You must be signed in to change notification settings - Fork 30
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
zod again #105
Comments
Good point, I've bumped the priority for supporting runtime validators such as zod. |
Thanks, and just to articulate the requirements again in a more simpler way and just to get started: This isn't really about zod, I should have named the issue differently since I am really not a big fan of zod:
|
Yes, that's the intention of #97. I've updated the issue's title to better reflect that. |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
tl;dr ded. rt validators such as zod are important for a DRY archittecture (edit: with rt validators i mean validators which do not compile ts types to rt validators)
Not that I am big fan of zod or other rt-validators but why I think we'd still need them:
Now, we can derive everything from that
This gets complex but it's actually pretty elegant, let's do an example: We want to add crud functions to a resource, we still maintain a rest-like file structure which also hosts all view files like with all modern framweworks. Let's have a recipe app and some path:
In this folder is everything, view files, server files, etc., e.g. with SvelteKit this would bee +page.svelte, +page.server.ts, +server.ts, etc.
Let's look at two RPCs in this context: create (recipe) and update (recipte), so we could just have a create.telefunc.ts file and because its location we know it's about recipe creation. The client, in our case, +page.svelte imports the call signature just with ./create.telefunc which is great because in a case of a refactor of the table naming
recipes
nothing has to be changed.But the client doesn't know the payload. Now, we could manually create the form but this doesn't help: The form is type-less anyway, so why would we need type-checking and hints for the call signature anyway (ofc there are other reasons)? So, because formdata is type-less we need rt validations or we just sent some random blob to the server without any client-side form validation.
If the client would also get some rt validators through create.telefunc it could do everything described in 1, 2 and 3 and again, in the case of a refactor, nothing had to be changed because the context (the folder) would stay the same, even if the folder names got renamed. And it is fully dry.
I think this is a huge opportunity since Telefunc is the only TS RPC solution with an elegant and simple architecture.
ps and re Zod: I don't care which rt validator is used but it should be an rt one and one which would still exist in some years
The text was updated successfully, but these errors were encountered: