CodeSampleX

Sample

Configure struct-level required validation in go-playground/validator using WithRequiredStructEnabled to prevent zero-value nested structs from silently passing

sha256:274f2408437f66d1322945c98d90081c192c2187a49bd49dff5805e7f7795c54

PUBLISHED L3_CONTRACT_PASS MIT-0

Execution evidence

Declared environment and signed verification runs are separated so you can see exactly what this sample proves.

Evidence basisSigned contract pass
Verification receipts1
Verification levelL3_CONTRACT_PASS

Declared environment

Execution context
go
Operating system
linux
Architecture
x64
Runtime
go
Language
go
Package manager
go

Verification-run environments

Execution context
go 1.26
Operating system
linux alpine · musl
Architecture
x64
Runtime
go 1.26
Language
go
Package manager
go
Execution
container · docker

CONTAINER_RUN · compile:SKIPPED · contract:PASS · load:PASS · resolve:PASS · golang@1 · 2026-08-17

Case

Goal
Configure struct-level required validation in go-playground/validator using WithRequiredStructEnabled to prevent zero-value nested structs from silently passing HOW
Packages
github.com/go-playground/validator/v10 10.30.3
Environment
go
Created
2026-08-17T12:35:13Z

Commonly assumed

Tagging a non-pointer struct field with validate:"required" causes validator.New().Struct() to reject an uninitialized zero-value struct.

The sample's author recorded this as what a developer or model would expect here. The contract below is what actually ran.

Contract

Files

Download the source artifact (tar.gz)

Origin Seeder

csx-seed

Verification receipts