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
SchemaA = Dry::Schema.JSON do
config.types = Types::TypeContainer
required(:type).value(eql?: "typeA")
required(:attributes).value(:hash) do
required(:foo).filled(:string)
end
end
SchemaB = Dry::Schema.JSON do
config.types = Types::TypeContainer
required(:type).value(eql?: "typeB")
required(:attributes).value(:hash) do
required(:bar).filled(:string)
end
end
class Contract < Dry::Validation::Contract
json do
config.validate_keys = true
config.types = Types::TypeContainer
optional(:features).value(:array).each do
schema(SchemaA) | schema(SchemaB)
end
end
end
If i validate the above contract with a valid value where the features array contains something that matches SchemaB then it passes, but it does fail if i pass something valid in that matches SchemaA but not SchemaB, returning errors complaining that the keys passed in are unexpected for SchemaB.
Switching the order of the schemas to schema(SchemaB) | schema(SchemaA) lets it pass again.
Also I noticed that If I remove the line config.validate_keys = true then i get the following error instead: "undefined method 'to_or' for #Array:0x000055b06a7f9d90`. Stacktrace:
If i validate the above contract with a valid value where the features array contains something that matches SchemaB then it passes, but it does fail if i pass something valid in that matches SchemaA but not SchemaB, returning errors complaining that the keys passed in are unexpected for SchemaB.
Switching the order of the schemas to
schema(SchemaB) | schema(SchemaA)
lets it pass again.Also I noticed that If I remove the line
config.validate_keys = true
then i get the following error instead: "undefined method 'to_or' for #Array:0x000055b06a7f9d90`. Stacktrace:FYI i'm passing in symbolized strings, in contrary to what should be working as mentioned here: #306 (comment)
The text was updated successfully, but these errors were encountered: