Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Add config to error if field is NOT set #7

Open
mitchellh opened this issue Nov 22, 2013 · 9 comments
Open

Add config to error if field is NOT set #7

mitchellh opened this issue Nov 22, 2013 · 9 comments

Comments

@mitchellh
Copy link
Owner

No description provided.

@mitchellh
Copy link
Owner Author

/cc @armon

@abursavich
Copy link
Contributor

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:

  1. "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.
  2. "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.

@mitchellh
Copy link
Owner Author

@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.

@bsideup
Copy link

bsideup commented Feb 3, 2016

👍 required fields would be great. Any progress on it?

@BrendanBall
Copy link

so it's now 2018, any progress?

@bonifaido
Copy link

I have submitted #167 which implements this.

@HavaH123
Copy link

HavaH123 commented Dec 1, 2020

+1 for this
Looking for this to be configurable, similar to something like #27

@programmer04
Copy link

There is another PR with this useful feature too #225. Please choose one and merge 🎉

@D-MarcFrank
Copy link

Very useful for my requirements - please merge 👍

adriansmares pushed a commit to adriansmares/mapstructure that referenced this issue Feb 28, 2024
…d-fields

Fix untagged field decoding in case of decode to struct
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

Successfully merging a pull request may close this issue.

8 participants