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

Feature request: Use validator on dynamic nested maps #224

Closed
sabloger opened this issue Sep 10, 2017 · 1 comment · Fixed by #338
Closed

Feature request: Use validator on dynamic nested maps #224

sabloger opened this issue Sep 10, 2017 · 1 comment · Fixed by #338

Comments

@sabloger
Copy link

sabloger commented Sep 10, 2017

Hi,
I want to validate nested maps with a mapped validate map!
example:

var mapTemplate = map[string]interface{}{
	"name":"required,alpha",
	"family":"required,alpha",
	"email":"required,email",
	"cell-phone":"numeric",
	"address":map[string]interface{}{
		"line1":"required,alphanum",
		"line2":"alphanum",
		"postal-code":"numeric",
	},
}

var inputMap = map[string]interface{}{
	"name":"Bob",
	"family":"Smith",
	"email":"foo@bar.baz",
	"address":map[string]interface{}{
		"line1":"",
		"line2":"",
		"postal-code":"",
	},
}

func validate() {
	govalidator.MapValidate(mapTemplate , inputMap)
}
@sabloger
Copy link
Author

I need it to validate request inputs!

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.

2 participants