Asset info specific validators.
(a AssetModel)
| 13 | // Asset info specific validators. |
| 14 | |
| 15 | func ValidateAssetRequiredKeys(a AssetModel) error { |
| 16 | var fields []string |
| 17 | if a.Name != nil && !isEmpty(*a.Name) { |
| 18 | fields = append(fields, "name") |
| 19 | } |
| 20 | if a.Symbol != nil && !isEmpty(*a.Symbol) { |
| 21 | fields = append(fields, "symbol") |
| 22 | } |
| 23 | if a.Type != nil && !isEmpty(*a.Type) { |
| 24 | fields = append(fields, "type") |
| 25 | } |
| 26 | if a.Decimals != nil { |
| 27 | fields = append(fields, "decimals") |
| 28 | } |
| 29 | if a.Description != nil && !isEmpty(*a.Description) { |
| 30 | fields = append(fields, "description") |
| 31 | } |
| 32 | if a.Website != nil { |
| 33 | fields = append(fields, "website") |
| 34 | } |
| 35 | if a.Explorer != nil && !isEmpty(*a.Explorer) { |
| 36 | fields = append(fields, "explorer") |
| 37 | } |
| 38 | if a.Status != nil && !isEmpty(*a.Status) { |
| 39 | fields = append(fields, "status") |
| 40 | } |
| 41 | if a.ID != nil && !isEmpty(*a.ID) { |
| 42 | fields = append(fields, "id") |
| 43 | } |
| 44 | |
| 45 | if len(fields) != len(requiredAssetFields) { |
| 46 | return fmt.Errorf("%w: %s", validation.ErrMissingField, |
| 47 | strings.Join(str.Difference(requiredAssetFields, fields), ", ")) |
| 48 | } |
| 49 | |
| 50 | return nil |
| 51 | } |
| 52 | |
| 53 | func ValidateAssetType(assetType string, chain coin.Coin) error { |
| 54 | chainFromType, err := types.GetChainFromAssetType(assetType) |
no test coverage detected
searching dependent graphs…