dashbitco / nimble_options

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

use a struct to wrap a valid schema and skip schema validation #70

Closed lud closed 3 years ago

lud commented 3 years ago

See https://github.com/dashbitco/nimble_options/issues/69

This change makes possible to obtain a valid schema, and then validate options directly without validating the schema itself whenever options are to be validated.

I defined the struct directly in the NimbleOptions module, instead of creating a NimbleOptions.Schema module, because from there, I guess a couple options could be added to the struct, that would be passed into the validation, if someday validate/2 becomes validate/3 and support validation options.

(this is also why the flag is called schema_valid? and not just valid?)

Have a nice day :)

lud commented 3 years ago

One note though: The docs function do not work with the recursive_schema() fixture from the tests. I did not try to change to much things to make it work, as I guessed the recursive_schema was only to test documenting the NimbleOptions@options_schema itself.

josevalim commented 3 years ago

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

lud commented 3 years ago

Thank you both for the reviews and the merge!