-
Notifications
You must be signed in to change notification settings - Fork 1
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
Use FastAPI validation tricks #10
Comments
Why is this issue closed? In if (
len(resStartHour) != 2
or int(resStartHour[0]) < 0
or int(resStartHour[0]) > 23
or int(resStartHour[1]) < 0
or int(resStartHour[1]) > 59
): We are still checking the input in |
I see that problem happens because hour input is a string but I guess we can handle this later. So closing the issue again. |
In
backend/apps/task/semester_routers.py
, line 42 we haveWe should always validate user inputs before we process them. But it might be cleaner to do it using FastAPI features.
Here is the page describing validating body fields.
So instead of validating things in the function, we can validate things in the model and delegate FastAPI to do that.
In the model, it might be something like
They also mention the same tricks apply to query and path parameters.
The text was updated successfully, but these errors were encountered: