launchbadge/realworld-axum-sqlx

Missing input validations

abonander opened this issue · 1 comments

As pointed out by /u/LucasMathWalker on Reddit: https://www.reddit.com/r/rust/comments/shetb1/show_rrust_a_rust_implementation_of_the_realworld/hv42wuo/

Text inputs in various routes are not properly validated. That's an oversight on my part. Were I designing these routes from scratch I would have considered it, but the Realworld spec is silent on input validation so I wasn't thinking about it.

Where variables are given, pick reasonable values for the context but don't assume they are the same values between routes:

It would be interesting to use https://github.com/Keats/validator, it's almost exactly what I was thinking when I mentioned an input validator framework in the Reddit thread.

The only thing it's missing, IMO, is enforcement of validation via typestate, so you can't forget to apply validation before you access the struct fields. I've made the suggestion there: Keats/validator#185