Conditional validation not working
kukicola opened this issue · 3 comments
kukicola commented
Hello
Version 1.0.0 broke my validation:
validates :avatar, content_type: ALLOWED_CONTENT_TYPES, size: { less_than: 10.megabytes }, if: -> { attachment_changes['avatar'] }
Failure/Error: validates :avatar, content_type: ALLOWED_CONTENT_TYPES, size: { less_than: 10.megabytes }, if: -> { attachment_changes['avatar'] }
ArgumentError:
wrong number of arguments (given 1, expected 0)
after removing if
it works correctly. Maybe it's connected to https://github.com/igorkasyanchuk/active_storage_validations/pull/135/files ?
igorkasyanchuk commented
@gr8bit, @StefSchenkelaars is it something that you can look?
@kukicola if possible maybe you can fork and create a fix?
gr8bit commented
I will look into it. From a first guess, I think if
might be picked up in the proc unfolding and get the record passed inside which the proc doesn't want.
gr8bit commented
@igorkasyanchuk fixed and added tests for the case. :)