In 0.x it was possible to make schemas have different form based on a rule or an option
SCHEMA = Dry::Validation.JSON do
configure do
option :product
def use_outcome_hash?
product.eql?('fizz')
end
end
required(:outcome).filled
rule(validate_outcome: [:outcome]) do |outcome|
use_outcome_hash?.then(outcome.schema(OUTCOME))
end
end
I am looking to migrate to 1.x because 0.x doesn’t seem to play nicely with ruby 2.7.
I haven’t been able to find similar functionality in 1.x is there any way to do it or do I have to create a separate schema for each scenario?