You can not select more than 25 topics
Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.
28 lines
645 B
28 lines
645 B
package market |
|
|
|
import ( |
|
"errors" |
|
"fmt" |
|
"sig-pub/api/pb" |
|
"sig-pub/pkg/data/entity" |
|
"sig-pub/pkg/types" |
|
"sig-pub/pkg/utils/validator" |
|
) |
|
|
|
// 检查交易产品基础信息 |
|
func validateTradeInstance(inst *entity.TradeInstance) (err error) { |
|
if inst == nil { |
|
return errors.New("inst is nil") |
|
} |
|
if validator.IsAnyBlank(inst.InstId, inst.InstPair, inst.InstCoin) { |
|
return errors.New("InstId InstPair InstCoin can't be blank") |
|
} |
|
// todo validate others |
|
for _, ex := range inst.Exchanges { |
|
_, ok := types.ExchangePBParse(pb.Exchange(ex.Exchange)) |
|
if !ok { |
|
return fmt.Errorf("exchange %d not valid", ex.Exchange) |
|
} |
|
} |
|
return |
|
}
|
|
|