You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
Inconsistent errors using struct extension with nested arrays and query parameters. No issues with single element arrays.
To Reproduce
classFilterStruct < Dry::Structattribute?:candidate_ids,Types::Array.of(Types::Params::Integer)endclassFiltersSchema < Dry::Schema::ParamsDry::Schema.load_extensions(:struct)definedooptional(:filters).hash(FilterStruct)endendFiltersSchema.new.call(filters: {candidate_ids: ["1"]}).errors.to_h# "1" is valid (single element array)=>{}FiltersSchema.new.call(filters: {candidate_ids: ["m","1"]}).errors.to_h# now "1" is invalid:=>{:filters=>{:candidate_ids=>{0=>["must be an integer"],1=>["must be an integer"]}}}
Expected behavior
Using struct extension, I would expect:
FiltersSchema.new.call(filters: {candidate_ids: ["1"]}).errors.to_h# "1" is valid:=>{}FiltersSchema.new.call(filters: {candidate_ids: ["m","1"]}).errors.to_h# "1" is still valid:=>{:filters=>{:candidate_ids=>{0=>["must be an integer"]}}}
which would be consistent with errors when struct extension is not being used:
classFiltersHashSchema < Dry::Schema::Paramsdefinedooptional(:filters).hashdooptional(:candidate_ids).filled(Types::Array.of(Types::Params::Integer))endendendFiltersHashSchema.new.call(filters: {candidate_ids: ["1"]}).errors.to_h# "1" is valid:=>{}FiltersHashSchema.new.call(filters: {candidate_ids: ["m","1"]}).errors.to_h# "1" is still valid:=>{:filters=>{:candidate_ids=>{0=>["must be an integer"]}}}
Describe the bug
Inconsistent errors using struct extension with nested arrays and query parameters. No issues with single element arrays.
To Reproduce
Expected behavior
Using struct extension, I would expect:
which would be consistent with errors when struct extension is not being used:
My environment
The text was updated successfully, but these errors were encountered: