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

Nested validation doesn't working #124

Open
ziasultan2 opened this issue Nov 14, 2023 · 1 comment
Open

Nested validation doesn't working #124

ziasultan2 opened this issue Nov 14, 2023 · 1 comment

Comments

@ziasultan2
Copy link

{
    "pnr": "bddddd",
    "quantity": 100,
    "flightType": "direct",
    "platform": {
        "groupWindowOffice": true,
        "groupWindowB2B": false,
        "serpOffice": true,
        "serpB2B": false
    }
}

I want to validate the platform nested struct but it doesn't validating. Further more it gives me error if I try to create rules like document. So I've to do it like this way "platform.*"

	rules := govalidator.MapData{
		"pnr":         []string{"required"},
		"quantity":    []string{"required"},
		"platform.groupWindowOffice": []string{"required"},
		"platform.groupWindowB2B":    []string{"required"},
		"platform.serpOffice":        []string{"required"},
		"platform.serpB2B":           []string{"required"},
	}

But this is not validating the nested data it always shows me data required. Will you please help me to find the solution

@Kirari04
Copy link

There is an example of a nested struct validation but it it might get things wrong if the nested struct has the same keys as the parent: https://github.com/thedevsaddam/govalidator/blob/master/doc/NESTED_STRUCT.md

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

No branches or pull requests

2 participants