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 map options in validate/2 when schema is a list #130

Merged
merged 1 commit into from
Aug 1, 2024

Conversation

cheerfulstoic
Copy link
Contributor

If I have the following:

NimbleOptions.validate(opts, NimbleOptions.new!(schema))

Everything works fine, but if I do:

NimbleOptions.validate(opts, schema)

It doesn't work 😢

@josevalim
Copy link
Member

Can you please add a test as well? Thank you!

It works when the schema is a NimbleOptions struct because of the function match, but not when it's just a list
@cheerfulstoic
Copy link
Contributor Author

Right, of course! Done!

I temporarily put in a if(is_map(options), do: IO.inspect(options)) in validate/2 to confirm that none of the tests were receiving a map as the first argument. I thought to make all of the tests use opts_to_type to exercise both the list and map versions of options, but I just went for a sanity test here assuming for now that if you pass in a map it will work everywhere the same as a list 🤷

@josevalim josevalim merged commit 2ccc151 into dashbitco:main Aug 1, 2024
2 checks passed
@josevalim
Copy link
Member

💚 💙 💜 💛 ❤️

@cheerfulstoic cheerfulstoic deleted the patch-1 branch August 1, 2024 13:56
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants