Skip to content

Commit 961375b

Browse files
authored
docs: clarify fieldexcludes behavior (#1610)
## Fixes Or Enhances Fixes #663. Clarifies the `fieldexcludes` documentation to match the current implementation: - the parameter names another struct field; - validation checks that the current field's string value does not contain that field's value; - validation succeeds when the referenced field cannot be resolved; - the package documentation now uses the registered `fieldexcludes` tag instead of the nonexistent `excludesfield` spelling. No runtime behavior or public API changes. ### Verification - `go test -run '^TestFieldExcludes$' .` - `make test` - `golangci-lint v2.12.2 run` - `go doc .` ### AI assistance disclosure AI assistance was used to search for a non-duplicated contribution candidate, inspect the implementation and existing tests, draft the documentation wording, and run verification commands. Affected files: `README.md` and `doc.go`. Human validation required before submission: review the final two-file diff, confirm the wording matches `fieldExcludes` and `TestFieldExcludes`, and confirm the commands above passed. The contributor remains responsible for the change and should be able to explain it without AI assistance. **Make sure that you've checked the boxes below before you submit PR:** - [x] Tests exist that cover this behavior (`TestFieldExcludes`). @go-playground/validator-maintainers
1 parent 74dd82a commit 961375b

2 files changed

Lines changed: 7 additions & 6 deletions

File tree

README.md

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -85,7 +85,7 @@ validate := validator.New(validator.WithRequiredStructEnabled())
8585
| eqcsfield | Field Equals Another Field (relative)|
8686
| eqfield | Field Equals Another Field |
8787
| fieldcontains | Check the indicated characters are present in the Field |
88-
| fieldexcludes | Check the indicated characters are not present in the field |
88+
| fieldexcludes | Current field does not contain another field's value |
8989
| gtcsfield | Field Greater Than Another Relative Field |
9090
| gtecsfield | Field Greater Than or Equal To Another Relative Field |
9191
| gtefield | Field Greater Than or Equal To Another Field |

doc.go

Lines changed: 6 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -803,13 +803,14 @@ other types.
803803
804804
Usage: containsfield=InnerStructField.Field
805805
806-
# Field Excludes Another Field
806+
# Field Excludes Another Field's Value
807807
808-
This does the same as excludes except for struct fields. It should only be used
809-
with string types. See the behavior of reflect.Value.String() for behavior on
810-
other types.
808+
This validates that the current field's string value does not contain the
809+
string value of the field named by the parameter. It should only be used with
810+
string types. If the referenced field cannot be resolved, validation succeeds.
811+
See the behavior of reflect.Value.String() for behavior on other types.
811812
812-
Usage: excludesfield=InnerStructField.Field
813+
Usage: fieldexcludes=InnerStructField.Field
813814
814815
# Unique
815816

0 commit comments

Comments
 (0)