github.com/kaptinlin/jsonschema@v0.4.6/examples/struct-validation/README.md (about)

     1  # Struct Validation Example
     2  
     3  Validate Go structs directly without map conversion.
     4  
     5  ## What it shows
     6  
     7  - `ValidateStruct()` method for direct struct validation
     8  - Auto-detection with `Validate()` method
     9  - JSON tags are automatically handled
    10  
    11  ## Benefits
    12  
    13  - Better performance than map-based validation
    14  - Type safety with Go structs
    15  - Automatic handling of `omitempty` and field renaming
    16  
    17  ## Run
    18  
    19  ```bash
    20  go run main.go
    21  ```
    22  
    23  ## Output
    24  
    25  ```
    26  ✅ Valid struct passed
    27  ❌ Invalid struct failed:
    28    - age: [Value should be at least 18]
    29  
    30  Using general Validate method:
    31  ✅ Auto-detected struct validation passed
    32  ```