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

[commandhandler] Giving missing field error for a struct containing private fields only #215

Open
apterf opened this issue Aug 3, 2018 · 1 comment

Comments

@apterf
Copy link
Contributor

apterf commented Aug 3, 2018

Problem

When defining a struct with private fields only as command data, missing field error is always thrown.

Problem is caused by private fields are skipped and default checking result is always true.
https://github.com/looplab/eventhorizon/blob/master/command.go#L159-L167

e.g. 1

type PrivateStruct struct {
	name string
	age  int
}

e.g. 2

type customTime time.Time

Suggestion

Set the default result of struct checking as false
https://github.com/looplab/eventhorizon/blob/master/command.go#L160

And suggest to use validator for custom struct:
https://github.com/looplab/eventhorizon/blob/master/middleware/commandhandler/validator/commandhandler.go

@maxekman
Copy link
Member

maxekman commented Sep 6, 2018

Good suggestion!

@maxekman maxekman changed the title Giving missing field error for a struct containing private fields only [commandhandler] Giving missing field error for a struct containing private fields only Sep 6, 2018
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Development

No branches or pull requests

2 participants