class PostSchema < Dry::Validation::Contract
params do
required(:title).value(:string, size: 20)
required(:content).value(:string, size: 50)
end
rule do
# prevent this rule to execute if shema validation did not passed
end
end
我目前的工作是使用 result.schema_result.success?。即使这个工作,但我查看源代码https://github.com/dry-rb/dry-validation/blob/master/lib/dry/validation/result.rb#L41。它是私有 api。有人对此有任何想法吗?