サンプル
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
実行証拠
宣言環境と署名済み検証実行を分け、証明範囲を明確にします。
証拠の基準署名済みコントラクト合格
検証レシート1
検証レベルL3_CONTRACT_PASS
宣言された環境
- 実行コンテキスト
- go
- OS
- linux
- アーキテクチャ
- x64
- ランタイム
- go
- 言語
- go
- パッケージマネージャー
- go
検証実行環境
- 実行コンテキスト
- go 1.26
- OS
- linux alpine · musl
- アーキテクチャ
- x64
- ランタイム
- go 1.26
- 言語
- go
- パッケージマネージャー
- go
- 実行方式
- container · docker
CONTAINER_RUN · compile:SKIPPED · contract:PASS · load:PASS · resolve:PASS · golang@1 · 2026-08-17
ケース
- ゴール
- Configure struct-level required validation in go-playground/validator using WithRequiredStructEnabled to prevent zero-value nested structs from silently passing HOW
- パッケージ
-
github.com/go-playground/validator/v10 10.30.3
- 環境
- go
- 作成日
- 2026-08-17T12:35:13Z
よくある思い込み
Tagging a non-pointer struct field with validate:"required" causes validator.New().Struct() to reject an uninitialized zero-value struct.
このサンプルの作者が、ここで開発者やモデルが期待するであろうこととして記録したもの。下の契約が実際に実行されたものだ。
コントラクト
- validator.New() ignores validate:"required" on non-pointer struct fields and returns nil for zero-value structs, while validator.WithRequiredStructEnabled() causes validation to fail with a required tag error on the struct field.
- Populating the non-pointer struct fields satisfies the required tag under both default and WithRequiredStructEnabled validator instances.
- Zero-value structs containing inner required fields fail on the outer struct when WithRequiredStructEnabled is active, rather than only reporting inner fields.
ファイル
- NOTES.md
- config.go
- config_test.go
- csx.json
- go.mod
- go.sum
ソースアーティファクトをダウンロード (tar.gz)
オリジンシーダー
csx-seed
検証レシート
- go 1.26 · linux alpine/x64 · docker · CONTAINER_RUN · compile:SKIPPED · contract:PASS · load:PASS · resolve:PASS · golang@1 · 2026-08-17 · ed25519:d91480838ac982c9