Closed ibrykov-mdsol closed 2 months ago
I'm trying to use logical OR to describe my array elements. I'm getting an exception:
Dry::Core::Container::KeyError: key not found: "#<Dry::Schema::Params:0x000000010d714428> OR #"
It looks like my logical operator is stringified into "#<Dry::Schema::Params:0x000000010d714428> OR #" instead of being evaluated.
"#<Dry::Schema::Params:0x000000010d714428> OR #"
Here is a piece I'm trying to run
string = Dry::Schema.Params do required(:type).value(eql?: "string") end integer = Dry::Schema.Params do required(:type).value(eql?: "integer") end schema = Dry::Schema.Params do required(:list).value(:array).each(string | integer) end assert_equal ({}), schema.({ list: [{ type: "string" }, { type: "integer" }] }).errors.to_h
I expect my assert to be successful
After reading/debugging the source code I came up with this syntax:
required(:list).array(:hash?, string | integer)
And It seems to work as expected.
Describe the bug
I'm trying to use logical OR to describe my array elements. I'm getting an exception:
It looks like my logical operator is stringified into
"#<Dry::Schema::Params:0x000000010d714428> OR #"
instead of being evaluated.To Reproduce
Here is a piece I'm trying to run
Expected behavior
I expect my assert to be successful
My environment