Using a relationship in a validation (atomicly)
I couldn't easily find this in the docs, but can use refer to relationships (easily) in validations? For example, we have widgets with a width and x property. Widgets belong_to a Scene that have a width property. We want to make sure that a Widget's x + width property is less than it's parent Scene's width?
I assume you need to use a custom validation for this. But can you make that custom validation atomic somehow?
1 Reply
I have used a atomic validation with exists on a relationship, so I assume it should work https://hexdocs.pm/ash/validations.html#atomic-validations
For atomic, you just need to implement the atomic callback in the change module