Skip to content
Init is coming / May 19 - 23
Back

Data validation (ZOD, ...)

  • 1
  • Functions
Brave
16 Dec, 2023, 17:11

If I want to validate the data users can put in the database I have to use functions. Is there a better way to do data validation then initiating ZOD in every single function and adding a schema for every function individually? I also believe that this could waste a lot of resources.

TL;DR
The thread discusses the challenge of data validation and the potential resource wastage in using ZOD (a schema validation library) for every function individually. The thread suggests the idea of having multiple endpoints and using a framework to maintain 1 function with multiple endpoints, making the code more readable. The suggestion also includes the possibility of introducing `.before` and `.after` events in future iterations. The thread doesn't provide a specific solution for data validation, but it suggests exploring alternatives to ZOD for more efficient validation.
Meldiron
17 Dec, 2023, 12:14

Hey 👋 For simpler maintenance, I would have 1 function with multiple endpoints. This makes your function's code larger, but with use of some framework, it should be very readable when split across multiple files.

Meldiron
17 Dec, 2023, 12:15

If next iteration of functions goes well (performance-focused), I will pitch idea of .before and .after events. Before events would run syncoronously, and could allow/deny the action - for example document creation. For now, best approach is to execute function from client, and create document inside function

Brave
17 Dec, 2023, 12:33

What do you mean by „multiple endpoints“?

Brave
17 Dec, 2023, 12:33

This would be insane! Love the idea 🤩

Reply

Reply to this thread by joining our Discord

Reply on Discord

Need support?

Join our Discord

Get community support by joining our Discord server.

Join Discord

Get premium support

Join Appwrite Pro and get email support from our team.

Learn more