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

Add baked in validators for containsfield and excludesfield #424

Merged

Conversation

fharding1
Copy link
Contributor

  • Tests exist or have been written that cover this particular change.

Change Details:

  • Adds containsfield baked in validator, as well as tests and documentation for containsfield.
  • Adds excludesfield baked in validator, as well as tests and documentation for excludesfield.

@go-playground/admins

@coveralls
Copy link

coveralls commented Nov 22, 2018

Coverage Status

Coverage remained the same at 100.0% when pulling 80d96ab on fharding1:baked-in-contains-excludes-field into 6079fcc on go-playground:v9.

@fharding1
Copy link
Contributor Author

I considered making these validators panic on non-string types but it looks like that isn't the behavior of other validators so I decided against it. I also considered adding support for fmt.Stringer but did not for the same reason.

@deankarn
Copy link
Contributor

deankarn commented Dec 8, 2018

Hey @fharding1 thanks for the PR!

I just have one request, can it be renamed to fieldcontains and fieldexcludes?
I was confused by the naming, I was reading it as if it was checking that the actual field was contained in the struct rather than containing the value.

@fharding1
Copy link
Contributor Author

@joeybloggs thanks for the feedback, done.

@fharding1
Copy link
Contributor Author

bump @joeybloggs

@deankarn
Copy link
Contributor

deankarn commented Jan 9, 2019

sorry @fharding1 got sick after the holidays and now the family is sick, trying to catch up on all this, sorry for the delay

@fharding1
Copy link
Contributor Author

No worries, I don't mean to be a bother, I just figured after a month you might have forgotten about it. Hope you and your family feels better soon!

@deankarn
Copy link
Contributor

deankarn commented Jan 9, 2019

@fharding1 no worries, I do forget sometimes too ;)

@deankarn deankarn merged commit 91d8193 into go-playground:v9 Jan 9, 2019
fairyhunter13 added a commit to fairyhunter13/validator that referenced this pull request Jul 12, 2020
…round#424)

* Add baked in validators for containsfield and excludesfield

* Add ContainsAndExcludes test

* Add NotEqual tests before AssertError

* Add tests for missing fields

* containsfield -> fieldcontains, excludesfield -> fieldexcludes
@axiaoxin
Copy link

excludesfield is still on godoc https://godoc.org/github.com/go-playground/validator#hdr-Field_Excludes_Another_Field

@jtyoui
Copy link

jtyoui commented Nov 24, 2021

😔 excludesfield and containsfield is still on godoc, this keeps reporting errors.
https://godoc.org/github.com/go-playground/validator#hdr-Field_Excludes_Another_Field

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.

None yet

5 participants