Skip to content

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

Open
@dluhhbiu

Description

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)

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions