go-ozzo / ozzo-validation

An idiomatic Go (golang) validation package. Supports configurable and extensible validation rules (validators) using normal language constructs instead of error-prone struct tags.
MIT License
3.73k stars 224 forks source link

How to validate nested json request #157

Closed henrycheung19 closed 3 years ago

henrycheung19 commented 3 years ago

Can you give an example of validating nested struct in JSON format? We cannot find the solution from the official document.

{
    "image": {
        "cover":"https://www.shutterstock.com/zh-Hant/image-photo/collection-fresh-red-apple-leaves-isolated-1914512347",
        "thumb":"https://www.shutterstock.com/zh-Hant/image-photo/collection-fresh-red-apple-leaves-isolated-1914512347"
    },
    "on_shelf":true,
    "is_latest":true,
    "original_price":1
}

validation.ValidateStruct cannot be nested.

However, nested JSON request is so common. Thanks.