AaronLasseigne / active_interaction

:briefcase: Manage application specific business logic.
MIT License
2.06k stars 136 forks source link

fix unexpected behavior around filters with validators #575

Open mogman1 opened 1 month ago

mogman1 commented 1 month ago

Fixes https://github.com/AaronLasseigne/active_interaction/issues/574

In my first example from that issue, the problem is that in the overridden run_validations! method, it doesn't end by calling errors.empty? the way that the Rails Validations class method does.

def run_validations!
  _run_validate_callbacks
  errors.empty?
end

In my second example, the issue is that on initialization @_interaction_inputs is set based on the original values sent over. Since nothing is being set, and there's no default value, it becomes nil. However, as updates are made to the filter value, nothing ever updates that original mapping so it will always fail. I went back and forth on how to address this, considering a callback to update the Input definition, but that didn't seem necessary when I had the actual context available. I also considered removing the now-unused inputs param, but didn't want to force an API change on you.