examples/

directory
v0.4.5 Latest Latest
Warning

This package is not in the latest version of its module.

Go to latest
Published: Jun 24, 2025 License: MIT

README ΒΆ

Examples

Practical examples demonstrating JSON Schema validation and unmarshaling with the new separated workflow.

Available Examples

🎯 Basic

Simple validation example showing valid and invalid data handling.

πŸ—οΈ Struct Validation

Direct struct validation without JSON marshaling for optimal performance.

πŸ”„ Multiple Input Types

Handle different data types (JSON bytes, maps, structs) with type-specific methods.

πŸ“¦ Unmarshaling

Validation + unmarshaling workflow with default value application.

βš™οΈ Dynamic Defaults

Dynamic default value generation using registered functions (e.g., timestamps, UUIDs).

πŸ“‹ Custom Formats

Custom format validation using registered functions.

⚠️ Error Handling

Comprehensive error handling patterns and validation failure management.

🌍 Internationalization

Multilingual error messages using Chinese (zh-Hans) and English locales.

πŸ—οΈ Constructor

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

Jump to

Keyboard shortcuts

? : This menu
/ : Search site
f or F : Jump to
y or Y : Canonical URL