Skip to content

Allow configuration for erroring on unknown keys #60

Description

@hlascelles

Potential new feature

It may be useful to allow sorbet-coerce to blow up on unknown keys

Steps to reproduce:

class Foo < T::Struct
  const :bar, String
end

TypeCoerce[Foo].new.from({ bar: "Hello", foo: "New key!" })
# => <Foo bar="Hello">

# The above succeeds, but I'd like it to (configurably) blow up as `foo` is not known.

Versions:

  • Ruby: 2.7
  • Sorbet: 0.5
  • Sorbet-Coerce: 0.5.0

I re-re-read the docs but don't think it is currently possible.
Is it, and if not would you like it to be, when configured?

Metadata

Metadata

Assignees

No one assigned

    Labels

    bugSomething isn't working

    Type

    No type

    Projects

    No projects

      Milestone

      No milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions