Skip to content

Conversation

@GrooveStomp
Copy link
Contributor

Adds two private functions in 'internal/module_config':

  • func (cfg ModuleConfig) collectMissing() []string
  • func findMissing(reflect.Value, string, string, []string)

These are unexported functions that aid in introspecting a datastructure to see if it has all its expected data.
These functions are implicitly invoked via:

  • func LoadModuleConfig(string) (ModuleConfig, error)

If there are errors then the program aborts with appropriate output.

Adds two private functions in 'internal/module_config':
- func (cfg ModuleConfig) collectMissing() []string
- func findMissing(reflect.Value, string, string, []string)

These are unexported functions that aid in introspecting a datastructure to see if it has all its expected data.
These functions are implicitly invoked via:
- func LoadModuleConfig(string) (ModuleConfig, error)

If there are errors then the program aborts with appropriate output.
config := ModuleConfig{}

var required = []string{}
fmt.Printf("%+#v\n", required)
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I assume this is not needed anymore? since we're treating non-omitempty as required

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Yeah, for sure! Thanks.

// If the value of the current node is equal to the zero value for its datatype
// and its struct field does *not* have a "omitempty" value, then we assume it
// is missing and add it to the resultset.
func findMissing(obj reflect.Value, path, metadata string, missing *[]string) {
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

🕶️ 👍

@GrooveStomp GrooveStomp merged commit c45c39e into main Dec 15, 2020
@GrooveStomp GrooveStomp deleted the 230-validate-zero-modules branch December 15, 2020 19:59
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

3 participants