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

go-playground / validator / 40968509375
73%
v8: 100%

Build:
Build:
LAST BUILD BRANCH: fix/duration-translations
DEFAULT BRANCH: v8
Ran 29 Oct 2026 10:47PM UTC
Jobs 1
Files 36
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

29 Oct 2026 10:47PM UTC coverage: 72.577%. Remained the same
40968509375

push

github

web-flow
Convert to time.Time before asserting in isNeField (#1619)

`nefield` panics on a named type whose underlying type is `time.Time`.

```go
type MyTime time.Time

type Test struct {
	Start MyTime
	End   MyTime `validate:"nefield=Start"`
}
validate.Struct(Test{Start: now, End: now})
// panic: interface conversion: interface {} is validator.MyTime, not time.Time
```

`isNeField`'s struct branch (`baked_in.go:1072`) guards on
`ConvertibleTo(timeType)`, which admits
any named type with a `time.Time` underlying — then asserts without
converting:

```go
if fieldType.ConvertibleTo(timeType) && currentField.Type().ConvertibleTo(timeType) {
	t := getValue(currentField).(time.Time)
	fieldTime := getValue(field).(time.Time)
```

`getValue` returns `val.Interface()` (`validator.go:516`), so the
dynamic type is still `MyTime`
and the assertion fails.

### It is the only one

Of the 28 `getValue(...).(time.Time)` sites in `baked_in.go`, 26 convert
first. The two that do
not are this pair. `isEqField:1402`, `isGteField:2326`,
`isGtField:2370`, `isLteField:2554`,
`isLtField:2598` and `isNeCrossStructField:1308` — the same not-equal
semantics in the sibling
family — all do:

```go
t := getValue(currentField.Convert(timeType)).(time.Time)
```

Same input through four of them, before the change:

```
eqfield   -> ok
ltfield   -> ok
necsfield -> ok
nefield   -> panic: interface conversion: interface {} is validator.MyTime, not time.Time
```

### Change

Two lines, adding the `Convert(timeType)` the siblings already have.
`Convert` is a no-op for a
plain `time.Time`, so nothing on the currently covered paths changes,
and the v10 API is untouched.

Test added next to the other `nefield` tests. Verified red/green by
reverting only `baked_in.go`
and keeping the test — it panics with `interface conversion: interface
{} is validator.namedTime`.
It also pins the semantics rather than just the absence of a panic:
equal named-time values must
fail the tag, different ones must pass.... (continued)

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

15019 of 20694 relevant lines covered (72.58%)

90.48 hits per line

Jobs
ID Job ID Ran Files Coverage
1 40968509375.1 29 Oct 2026 10:47PM UTC 36
72.58
GitHub Action Run
Source Files on build 40968509375
  • Tree
  • List 36
  • Changed 0
  • Source Changed 0
  • Coverage Changed 0
Coverage ∆ File Lines Relevant Covered Missed Hits/Line
  • Back to Repo
  • 5b09d8d4 on github
  • Prev Build on master (#40776322458)
  • Next Build on master (#40968705535)
STATUS · Troubleshooting · Open an Issue · Sales · Support · CAREERS · ENTERPRISE · START FREE TRIAL · SCHEDULE DEMO
ANNOUNCEMENTS · TWITTER · TOS & SLA · Supported CI Services · What's a CI service? · Automated Testing

© 2026 Coveralls, Inc