Closed Keats closed 6 months ago
Things that need to be done:
Things that would be very nice:
Why is moving to traits better than just calling plain functions, if I may ask?
It's more flexible, any type can implement them - they don't have to live in the validator crate.
Is there anybody working on the derive macro rewrite?
I don't think so - I was planning to work on it once I'm a bit further with Tera v2 but I would be happy if someone wants to tackle it!
I can try it this week, I'll open a PR
It's more flexible, any type can implement them - they don't have to live in the validator crate.
How would that work for the macro though? As in, would it be a custom
validator?
Also, I'm planning to write a crate that does not only validation, but also mutation. For example - if a mutator called lowercase
is applied on a String
type, it will automatically convert it into a lowercase string, and so on.
Would the next version of validator support mutation? If so, I can directly use this (would be happy to help writing it as well) instead of writing something separately.
How would that work for the macro though? As in, would it be a custom validator?
Not for the validators, for the data structures. You will be able to take whatever map/array/string type you want and implement the traits yourself rather than having them in the validator crate.
Would the next version of validator support mutation?
No, imo that's unrelated business. You could use a custom serde serializer/deserializer fn for that
Got it. Thanks for considering it. I'll try writing something over this week and see if I can make a crate out of it. I'll report back with any learnings I would have in case it helps with your next version.
Ok, maybe we do want to ship that PR now and do the other changes (eg error schema changes) in another version? No need to hold it out longer I think.
Thoughts?
I feel like this would be a good change in it's own right, if the change would linger waiting for additional, more complex changes, it might be best to just do separate versions for each of these significant changes.
Ok it's live!
Thanks everyone
This contains the work needed to make the lib use validation based on traits.