Closed lucasmazza closed 9 years ago
wow that was fast :) I left one comment, tell me what you think, cheers!
Just pushed the tests of having nullify_blank
and strict
working together, but looks like required
might not work as expected - since it is a piece of the strict
logic. Maybe extracting it to a module that has precedence over both strict
and nullify_blank
might improve this but I haven't looked deeper enough through the code.
required
flag means whether nil
is an acceptable value or not for a specific attribute, I suppose setting nullify_blank
implies that required
should be false
.
@solnic OK, so I think the current tests cover this case when all options are true
and we don't raise a coercion error when the nullable input is provided. I guess we are done with the implementation here, so let me know if we need to change/add something before merging this.
@lucasmazza awesome, thanks! I'm gonna merge it in and see how it works in my apps and then we could push it out in the next release. This will simplify rom-rails so that's really cool.
@solnic nice! I tested in my current project and it worked as expected - it isn't a large app but I've managed to remove our implementation of custom attribute classes that supported this behaviour with the configuration option directly.
Closes #310.
I did a simple implementation based on what the code that supports the
strict
option, so let me know if I shouldn't take down this road. I still want to give a review of my own on this later and update the README documenting this feature before getting this merged :smile:.