Closed gotar closed 4 years ago
Thanks for sharing this. I can see how this could be handy but the plan is actually to have "form objects" rather than using AR validation.
In the future please start a thread on our forum with a feature proposal rather than reporting an issue. We use issues for bug reports and approved feature requests only.
@solnic it’s useful in many cases so adding this to maybe a documentation will save a lot of people time.
@gotar it's not in line with the concept of validating data before passing to models, because of this it cannot be even documented, despite being handy in some cases. I'm not saying it's inherently wrong to handle validation like that, we just shouldn't document how to do something that doesn't follow architectural patterns we've been promoting for few years now.
I made something like this to automatically import dry-schema (contract) from my Custom class to a Rails model, so every tool (gem) that require model validation automatically use schema
Works like a charm, so maybe will be useful for someone, plus I think It's quire easy to add to dry-rails itself.