Skip to content

JSON schema contract failing to recognise valid input #720

Open
@RajatPawar

Description

@RajatPawar

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

Metadata

Metadata

Assignees

No one assigned

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions