LukasKalbertodt / confique

Type-safe, layered, light-weight, `serde`-based configuration library
https://docs.rs/confique
Apache License 2.0
167 stars 12 forks source link

Validation #16

Open LukasKalbertodt opened 1 year ago

LukasKalbertodt commented 1 year ago

A user defined function that is called when loading a config file. Mostly useful to automatically call .validate() on nested fields for example. Or maybe even add built-in attributes like non_empty for strings or something like that. This might increase the scope of this library too much though...

milesj commented 1 year ago

@LukasKalbertodt I would really love this. It's a major feature that config/figment do not have which is unfortunate.

Something liket his would be great.

#[config(validate = "some_func")]
pub field: String;

#[config(validate = Validate::NotEmpty)]
pub field: String;