Add config to error if field is NOT set
/cc @armon
I may take a stab at this if I find some time this weekend. Not to overly complicate things but it might be nice to have more fine grained control over which fields are required and which are not. I'd consider adding one or more tags related to this:
- "required" which would trigger an error if a specified field is omitted and the new config flag is enabled. Alternatively the new config flag wouldn't need to exist at all, but maybe you're importing someone else's type that has "required" fields and you don't want them to be required.
- "omissible" which would suppress an error if a specified field is omitted and the new config flag is enabled. I'm not sure it it makes sense to have this double up on "omitempty". It seems like they'd likely often be set together on the same field, but that's not a compelling enough reason to lump them together to me.
@ambify I think to begin, a blanket all required and all not required bool would make sense to the Config.
In the future, a better way to do it more fine grained would be good.
:+1: required fields would be great. Any progress on it?
so it's now 2018, any progress?
I have submitted https://github.com/mitchellh/mapstructure/pull/167 which implements this.
+1 for this Looking for this to be configurable, similar to something like https://github.com/mitchellh/mapstructure/pull/27
There is another PR with this useful feature too https://github.com/mitchellh/mapstructure/pull/225. Please choose one and merge 🎉
Very useful for my requirements - please merge :+1: