I discovered that this validation still works
validates :name, presence: true, if: (spa) -> { spa.name_required && other_name.blank? }
This has a lambda with an argument, but the argument isn't used for the other_name
check
I found that when I removed the argument to the lambda it still works
validates :name, presence: true, if: -> { name_required && other_name.blank? }
The documentation says we should be creating procs, see https://guides.rubyonrails.org/active_record_validations.html#using-a-symbol-with-if-and-unless
I think this works because a lambda is a closure inside the object it's defined so the object's methods are available.
Question is, why does the Active Record documentation say use a proc with an argument? Is using a lambda like this wrong in some way?