-
Notifications
You must be signed in to change notification settings - Fork 1.3k
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
added excluded_if/excluded_unless tags + tests #847
added excluded_if/excluded_unless tags + tests #847
Conversation
This would be useful, can someone please review this? |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Looking great overall, does it work with nested fields though?
eg. If one wanted to require unless field in a parent or child structs field?
baked_in.go
Outdated
if len(params)%2 != 0 { | ||
panic(fmt.Sprintf("Bad param number for excluded_unless %s", fl.FieldName())) | ||
} | ||
fmt.Println(params[0], params[1], requireCheckFieldValue(fl, params[0], params[1], false), !hasValue(fl)) |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Leftover debug?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Yep, 100% a leftover. Pushed with changes.
I'll add a test for nested fields today (hopefully).
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
OK, tests for nested (inner) structs were added.
Golangci-lint is very angry though, but locally runs fine (I'm running 1.45.2 though).
I also don't see a golangci lint yaml config in the root dir...
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
@deankarn anything else I need to do for this?
Fixes Or Enhances
Adds
excluded_if
andexcluded_unless
tags with tests.Make sure that you've checked the boxes below before you submit PR:
@go-playground/validator-maintainers