Skip to content
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

Add schema validator when sending or receiving requests #479

Open
smartspot2 opened this issue Jul 26, 2024 · 0 comments
Open

Add schema validator when sending or receiving requests #479

smartspot2 opened this issue Jul 26, 2024 · 0 comments
Labels
enhancement New feature or request good first issue Good for newcomers javascript Pull requests that update Javascript code

Comments

@smartspot2
Copy link
Member

smartspot2 commented Jul 26, 2024

When we send data to the Django server or receive data from the Django server, we currently have no way of actually ensuring that the data is of the correct format.

Adding a schema validator can give us this insurance, while also making it very explicit what data types we're passing around are. Further, this allows for clearer documentation on the actual data being passed around between the frontend and backend. The most popular validator used with React/TS is Zod.

We should update all of our queries to include Zod as a preprocessing step, migrating the types to use Zod schemas (with types inferred from them). Other components shouldn't need to be modified, since all of this validation should be done within the custom react-query hooks, and the same data is passed to other components. Some imports may need to be changed though, to align with the potentially new locations for the Zod schemas.

@smartspot2 smartspot2 added enhancement New feature or request good first issue Good for newcomers javascript Pull requests that update Javascript code labels Jul 26, 2024
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
enhancement New feature or request good first issue Good for newcomers javascript Pull requests that update Javascript code
Projects
None yet
Development

No branches or pull requests

1 participant