Examples
Practical examples demonstrating JSON Schema validation and unmarshaling with the new separated workflow.
Available Examples
Simple validation example showing valid and invalid data handling.
Direct struct validation without JSON marshaling for optimal performance.
Handle different data types (JSON bytes, maps, structs) with type-specific methods.
Validation + unmarshaling workflow with default value application.
Dynamic default value generation using registered functions (e.g., timestamps, UUIDs).
Comprehensive error handling patterns and validation failure management.
Multilingual error messages using Chinese (zh-Hans) and English locales.
Schema creation using fluent constructor API with keywords and validation.
Running Examples
# Run any example
cd <example-directory>
go run main.go
# Or run from project root (for single-file examples)
go run examples/<example-name>/main.go
# For dynamic defaults example
cd examples/dynamic-defaults
go run dynamic_defaults.go