Open rickychilcott opened 4 years ago
I tried to resolve this and I figured out that this fails ONLY when the keys are provided as strings, similarly as mentioned here - https://github.com/dry-rb/dry-schema/issues/296
I'll try to propose a solution for this, in a meantime you can work around this by changing your hash keys to symbols.
Unfortunately when composed schemas are passed as an argument, it's not working, but this should work:
Schema = Dry::Schema.Params do
required(:definitions).filled(:array).each(:hash) { ScaleSchema | QuestionSchema }
end
@solnic this example did not return an error, but it also did not bring values in the result
# ...
Schema = Dry::Schema.Params do
required(:definitions).filled(:array).each(:hash) { ScaleSchema | QuestionSchema }
end
validator = Schema.call(valid_hash)
validator.to_h
=> {:definitions=>[{}, {}]}
Describe the bug
It appears when using an
or
ed schema in an array, schemas nested below that will not pass validation when they should.To Reproduce
Expected behavior
Expected no errors to be be found by the validator. This may not work until 2.0 based on the experimental nature of composing schemas (https://dry-rb.org/gems/dry-schema/1.5/advanced/composing-schemas/).
Your environment