somehowchris / rocket-validation

A guard to validate data received by rocket via validator
16 stars 4 forks source link

Support for ValidatedArgs #15

Open NiekVelde opened 2 years ago

NiekVelde commented 2 years ago

Awesome addition to this package would be support for custom validation arguments. Which is a functionality of the Validation package. I've worked something out inside of my own project for my use case of passing a database connection to my custom validation rule. This works okay, but with my still limited knowledge of Rust my implementation only works for one single struct, otherwise I would of course have created a pull request for this functionality. If I can help in any way, let me know.

somehowchris commented 1 year ago

Ok, so lets ignore the technical part of how to integrate such a thing for a second.

The main part here for me is: "Should it be able to do this?". From my point of view, this crate should help validate input data and not validate data itself. The difference being, you should not mix performing serialization, transformation, validation and business logic in an app. Making sure something exists or doesn't exist is kind of validation but is part of business logic from my point of view. Validation has more to do with the shape and size of the data being passed to the handler of my business logic.

PS: I welcome you to open up a PR