| 643 | |
| 644 | |
| 645 | Option<Error> validateOfferFilters(const OfferFilters& offerFilters) |
| 646 | { |
| 647 | if (offerFilters.has_min_allocatable_resources()) { |
| 648 | foreach ( |
| 649 | const OfferFilters::ResourceQuantities& quantities, |
| 650 | offerFilters.min_allocatable_resources().quantities()) { |
| 651 | if (quantities.quantities().empty()) { |
| 652 | return Error("Resource quantities must contain at least one quantity"); |
| 653 | } |
| 654 | |
| 655 | // Use `auto` instead of `protobuf::MapPair<string, Value::>` since |
| 656 | // `foreach` is a macro and does not allow angle brackets. |
| 657 | foreach (auto&& quantity, quantities.quantities()) { |
| 658 | Option<Error> error = validateInputScalarValue(quantity.second.value()); |
| 659 | if (error.isSome()) { |
| 660 | return Error( |
| 661 | "Invalid resource quantity for '" + quantity.first + "': " + |
| 662 | error->message); |
| 663 | } |
| 664 | } |
| 665 | } |
| 666 | } |
| 667 | |
| 668 | return None(); |
| 669 | } |
| 670 | |
| 671 | Option<Error> validateInputScalarValue(double value) |
| 672 | { |