dashbitco / nimble_options

A tiny library for validating and documenting high-level options. 💽
Apache License 2.0
507 stars 38 forks source link

Allow map options in validate/2 when schema is a list #130

Closed cheerfulstoic closed 3 months ago

cheerfulstoic commented 3 months ago

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 commented 3 months ago

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

cheerfulstoic commented 3 months ago

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 commented 3 months ago

:green_heart: :blue_heart: :purple_heart: :yellow_heart: :heart: