AaronLasseigne / active_interaction

:briefcase: Manage application specific business logic.
MIT License
2.07k stars 137 forks source link

Wrong error message when use hash of array of hashes #576

Open dluhhbiu opened 3 months ago

dluhhbiu commented 3 months ago

Hello. I realized when use hash of array of hash then got wrong error message

class TestArrayOfHashes < ActiveInteraction::Base
  hash :data do
    array :test do
      hash do
        string :value
        string :value2
      end
    end
  end

  def execute
    inputs
  end
end

When I run next code, I get correct response

# code
TestArrayOfHashes.run!(data: { test: [{ value: 'foo', value2: 'bar' }] })
# response
{:data=>{"test"=>[{"value"=>"foo", "value2"=>"bar"}]}}

But next part of code works incorrect like my opinion

# code
TestArrayOfHashes.run!(data: { test: [{ value: 'foo', wrong_value: 'foo' }] })
# response
Data test required (ActiveInteraction::InvalidInteractionError)

Error is correct, but I expected something like Data test value2 required

Is it bug or correct behavior?

Version of gem active_interaction (5.3.0)