dashbitco / nimble_options

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

Add support for a {:struct, struct_name} type specifier #99

Closed aselder closed 1 year ago

josevalim commented 1 year ago

Thank you @aselder!

Can you please:

  1. Run mix format
  2. Change the docs.ex and add tests to ensure we generate the proper docs for it

?

aselder commented 1 year ago

@josevalim Done!

whatyouhide commented 1 year ago

@aselder this PR is failing on Elixir 1.9 (still supported by this library) because is_struct/2 was introduced later on. Can you move the check to the body of the function, and use something like Map.has_key?(struct, :__struct__) and struct.__struct__ == mod?

josevalim commented 1 year ago

We can pattern match as well:

match?(%^mod{}, value)
aselder commented 1 year ago

Any idea what a rough timeline for getting this released is? Trying decide if I launch a feature with out and go back and update later, or wait for this to make it out. Thanks!

aselder commented 1 year ago

@whatyouhide Thanks Andrea