• Home
  • Features
  • Pricing
  • Docs
  • Announcements
  • Sign In

go-playground / validator / 14717133330
74%
v8: 100%

Build:
Build:
LAST BUILD BRANCH: master
DEFAULT BRANCH: v8
Ran 28 Apr 2025 08:23PM UTC
Jobs 1
Files 34
Run time 1min
Badge
Embed ▾
README BADGES
x

If you need to use a raster PNG badge, change the '.svg' to '.png' in the link

Markdown

Textile

RDoc

HTML

Rst

28 Apr 2025 08:23PM UTC coverage: 73.655% (+0.002%) from 73.653%
14717133330

push

github

web-flow
Align required_without with the contract stated in the documentation (#1422)

## Fixes Or Enhances

Resolves #617 

Fixes `required_without` so that it aligns with the stated contract and
usage examples.

The
[docs](https://pkg.go.dev/github.com/go-playground/validator/v10#hdr-Required_Without)
valid usage to be:
```
// require the field if the Field1 is not present:
Usage: required_without=Field1

// require the field if the Field1 or Field2 is not present:
Usage: required_without=Field1 Field2
```

However, as show in this issue:
https://github.com/go-playground/validator/issues/617, you can only use
`required_without` on multiple fields like:

```golang
type Test struct {
    Field1 string `validator:required_without=Field2,required_without=Field3"
    ...
}
```

This PR aligns the behavior of the `required_without` validator such
that you can also use it as shown in the example:

```golang
type Test struct {
    Field1 string `validator:required_without=Field2 Field3"
    ...
}
```

**Make sure that you've checked the boxes below before you submit PR:**
- [x] Tests exist or have been written that cover this particular
change.

Note: Sorry for the duplication of #1324. I was cleaning up my profile
and deleted my fork before it could be merged.

@go-playground/validator-maintainers

5 of 5 new or added lines in 1 file covered. (100.0%)

14312 of 19431 relevant lines covered (73.66%)

73.65 hits per line

Jobs
ID Job ID Ran Files Coverage
1 14717133330.1 28 Apr 2025 08:23PM UTC 34
73.66
GitHub Action Run
Source Files on build 14717133330
  • Tree
  • List 34
  • Changed 1
  • Source Changed 0
  • Coverage Changed 1
Coverage ∆ File Lines Relevant Covered Missed Hits/Line
  • Back to Repo
  • 5b315127 on github
  • Prev Build on master (#14502823610)
  • Next Build on master (#14815339239)
STATUS · Troubleshooting · Open an Issue · Sales · Support · CAREERS · ENTERPRISE · START FREE · SCHEDULE DEMO
ANNOUNCEMENTS · TWITTER · TOS & SLA · Supported CI Services · What's a CI service? · Automated Testing

© 2025 Coveralls, Inc