dry-rb/dry-validation

JSON schema contract failing to recognise valid input

Open

#720 opened on 2022年11月15日

GitHub で見る
 (2 comments) (0 reactions) (0 assignees)Ruby (193 forks)github user discovery
bughelp wanted

Repository metrics

Stars
 (1,421 stars)
PR merge metrics
 (PR metrics pending)

説明

Describe the bug

A json schema that is not picking up on valid input.

To Reproduce

class TestContract < Dry::Validation::Contract
  json do
    required(:mykey?).value(:bool)
  end
end

input = JSON.parse('{"mykey?": true }')

result = TestContract.new.call(input)
# #<Dry::Validation::Result{} errors={:mykey?=>["is missing"]}>

result.to_h
# {}

result.errors
# #<Dry::Validation::MessageSet messages=[#<Dry::Schema::Message text="is missing" path=[:mykey?] predicate=:key? input={}>] options={}>

Expected behavior

It should have picked up the input since it was conforming to the schema.

My environment

  • Affects my production application: NO
  • Ruby version: 2.6.10
  • OS: macOS 12.6

コントリビューターガイド