Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Allow configuration for erroring on unknown keys #60

Open
hlascelles opened this issue Jul 5, 2022 · 3 comments
Open

Allow configuration for erroring on unknown keys #60

hlascelles opened this issue Jul 5, 2022 · 3 comments
Labels
bug Something isn't working

Comments

@hlascelles
Copy link
Contributor

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?

@hlascelles hlascelles added the bug Something isn't working label Jul 5, 2022
@mattxwang
Copy link
Contributor

Hi @hlascelles, this sounds like a reasonable feature request. Are you interested in implementing the feature/creating a PR? If not, I can add it to my backlog!

@hlascelles
Copy link
Contributor Author

Sorry for the delay... Just nipped this comment in before the anniversary.

If you think it would be quick for you, that would be great, please do add to backlog! I may try and have a go at some point myself, but not sure when...

@mattxwang
Copy link
Contributor

No worries @hlascelles! Unfortunately I don't work at CZI anymore (and don't have the keys to push, make releases, etc.). Hopefully someone else on the team could help you out - they should be able to cut a release if you open a PR yourself!

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
bug Something isn't working
Projects
None yet
Development

No branches or pull requests

2 participants