fusenapi/utils/validate/user_info.go

27 lines
564 B
Go
Raw Normal View History

package validate
import (
"encoding/json"
"errors"
)
type MerchantCategory struct {
CategoryId int64 `json:"category_id"`
}
func Validate(module *string, metadata *string) (interface{}, error) {
if *module == "merchant_category" {
var merchantCategory MerchantCategory
err := json.Unmarshal([]byte(*metadata), &merchantCategory)
if err != nil {
return nil, err
} else {
if merchantCategory.CategoryId == 0 {
return nil, errors.New("merchant_category.category_id is required")
}
return merchantCategory, nil
}
}
return nil, nil
}