Well, you hit the thing I hate about validations in ORMs. You really do want to validate submitted form, and not validate the model, because of the reasons above. In my opinion, this really is the major design flaw, in Rails and by shared genes in Phoenix.
I tend to work around the issue by creating “Form objects” or “Form modules/structs” and handling validations outside of the “model” layer altogether. Which is more work, but has it’s rewards. Combination of GitHub - CargoSense/vex: Data Validation for Elixir · GitHub and GitHub - appcues/exconstructor: An Elixir library for generating struct constructors that handle external data with ease. · GitHub does the job for me at the moment. But this is radical approach, you may not want to take.
In your case, you can define 2nd function head in your controller, that will catch the nil. And it would call the current function you have, explicitly passing a nil to the avatar field, so the validations kick in properly.






















