validate checks invariants on the converted rows. Catches upstream changes that produce structurally valid but semantically broken seed data, e.g. a renamed `cost` key that leaves every row with all-null prices.
(rows []priceRow)
| 176 | // data, e.g. a renamed `cost` key that leaves every row with all-null |
| 177 | // prices. |
| 178 | func validate(rows []priceRow) error { |
| 179 | for _, r := range rows { |
| 180 | if r.InputPrice != nil || r.OutputPrice != nil { |
| 181 | return nil |
| 182 | } |
| 183 | } |
| 184 | return xerrors.New("converted rows have no pricing data; upstream schema may have changed") |
| 185 | } |
| 186 | |
| 187 | // toMicros scales a price into integer micro-units (1 unit = 1,000,000), |
| 188 | // rounding to avoid float-truncation errors. Returns nil for nil input, and |