github.com/kaptinlin/jsonschema@v0.4.6/examples/error-handling/README.md (about) 1 # Error Handling Example 2 3 Shows different ways to handle validation errors and parse failures. 4 5 ## What it shows 6 7 - Multiple validation errors in a single validation 8 - Different error output formats 9 - JSON parsing errors 10 - Unmarshal validation errors 11 - Error type checking 12 13 ## Error Types 14 15 - **Validation errors**: Field-specific constraint violations 16 - **Parse errors**: Invalid JSON syntax 17 - **Unmarshal errors**: Validation failures during unmarshaling 18 19 ## Run 20 21 ```bash 22 go run main.go 23 ``` 24 25 ## Output 26 27 ``` 28 Error Handling Examples 29 ======================= 30 1. Multiple validation errors: 31 Errors: 32 - name: Value should be at least 2 characters long 33 - age: Value should be at least 18 34 - email: Unsupported format 'email' 35 - score: Value should be at most 100 36 37 2. Error list format: 38 - name: Value should be at least 2 characters long 39 - age: Value should be at least 18 40 - email: Unsupported format 'email' 41 - score: Value should be at most 100 42 43 3. JSON parse error: 44 JSON parsing failed 45 46 4. Unmarshal error: 47 Unmarshal failed: validation failed 48 Error type: validation 49 50 5. Successful validation: 51 ✅ Validation passed 52 ```