Validate performs basic sanity checks on the bundle.
()
| 75 | |
| 76 | // Validate performs basic sanity checks on the bundle. |
| 77 | func (b *Bundle) Validate() error { |
| 78 | if b.PrimaryURL != nil { |
| 79 | hasExchangeForPrimaryURL := false |
| 80 | primaryURLString := b.PrimaryURL.String() |
| 81 | for _, e := range b.Exchanges { |
| 82 | if e.Request.URL.String() == primaryURLString { |
| 83 | hasExchangeForPrimaryURL = true |
| 84 | break |
| 85 | } |
| 86 | } |
| 87 | if !hasExchangeForPrimaryURL { |
| 88 | return fmt.Errorf("bundle: No exchange for primary URL %v", b.PrimaryURL) |
| 89 | } |
| 90 | } |
| 91 | return nil |
| 92 | } |