You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
I'm a big fan of Litestar, but I've been a bit lost when it comes to finding the preferred best practices for actually validating data in a strict, security minded fashion, as the main Litestar docs are sadly lacking in that regard.
Fields like emails and passwords are the most obvious examples, but here both are just str all the places I could find. No minimum lengths, no validating that an email address is an actual email address, etc.
Along with other types and features for things like URLs, stripping whitespace, forcing lowercase, etc. So I was hoping to find something similar here (regardless of whether it comes from Litestar directly vs Msgspec). Along the lines of:
It seems like even a really solid example of how to do this on your own would be beneficial. Like a guide for the best way to do custom validation per field. But I can't find that either. Am I just missing something?
The text was updated successfully, but these errors were encountered:
I will let @cofin comment more on this. For completion sake (you probably know this), nothing is really stopping you from using Pydantic models with its validators and data types to do what you want.
I was purposefully trying things other than Pydantic, which led me to Litestar and msgspec. I came here because even though it sounds like those tools are production ready, I can't find examples of how people are doing these things needed for production anywhere.
For what it's worth, there's already tons and tons of examples of how to do this stuff with Pydantic everywhere. We don't need anymore, IMO. What I would really appreciate though is how do you do this with Litestar and msgspec?
Summary
I'm a big fan of Litestar, but I've been a bit lost when it comes to finding the preferred best practices for actually validating data in a strict, security minded fashion, as the main Litestar docs are sadly lacking in that regard.
Fields like emails and passwords are the most obvious examples, but here both are just
str
all the places I could find. No minimum lengths, no validating that an email address is an actual email address, etc.Basic Example
Pydantic has an
EmailStr
type: https://docs.pydantic.dev/2.0/usage/types/string_types/#emailstrAlong with other types and features for things like URLs, stripping whitespace, forcing lowercase, etc. So I was hoping to find something similar here (regardless of whether it comes from Litestar directly vs Msgspec). Along the lines of:
Drawbacks and Impact
I don't really see any drawbacks to doing this.
Unresolved questions
It seems like even a really solid example of how to do this on your own would be beneficial. Like a guide for the best way to do custom validation per field. But I can't find that either. Am I just missing something?
The text was updated successfully, but these errors were encountered: