dashbitco / nimble_options

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

Support nested schemas in the :or type #55

Closed whatyouhide closed 3 years ago

whatyouhide commented 3 years ago

@josevalim I completely overlooked nested schemas in #54. This to me seems like the best (= least horrible, still pretty ugly) way of dealing with them.

schema = [
  docs: [
    type: {:or, [:boolean, {:keyword_list, enabled: [type: :boolean]}]}
  ]
]

Thoughts?

josevalim commented 3 years ago

This should also work:


schema = [
  docs: [
    type: {:or, [:boolean, keyword_list: [enabled: [type: :boolean]]]}
  ]
]

Is it better? Thoughts?
whatyouhide commented 3 years ago

@josevalim that's the same data structure, yeah, it works in the same way. Do you mean I should update the examples?