[dry-schema] Unexpected results when key ends with question mark

Hi everyone! :wave:

I’m new here, recently I tried to use dry-schema for data validation in existing app, I have a couple of use cases when hash keys end with question mark, like { 'terms_of_usage?' => 'Y' }.

Looks like dry-schema ignores such keys, here the code:

MySchema = Dry::Schema.Params do
  required(:some?).filled(:string)
end

MySchema.('some?' => 'val')
=> #<Dry::Schema::Result{} errors={:some?=>["is missing"]}>

Is it expected behaviour? I didn’t find any mention of this in docs, sorry if I’m wrong.

I’m using:
ruby 2.6.5
dry-schema 1.4.3

hey Pavel!

No, this is not expected behavior. I think it’s because keys with question marks denote optional keys in dry-types, which is used under the hood to coerce input. Please report an issue about it and I’ll fix it.

Cheers!

1 Like