| OLD | NEW |
| 1 // Copyright 2016 The Chromium Authors. All rights reserved. | 1 // Copyright 2016 The Chromium Authors. All rights reserved. |
| 2 // Use of this source code is governed by a BSD-style license that can be | 2 // Use of this source code is governed by a BSD-style license that can be |
| 3 // found in the LICENSE file. | 3 // found in the LICENSE file. |
| 4 | 4 |
| 5 #include "components/payments/payment_details_validation.h" | 5 #include "components/payments/payment_details_validation.h" |
| 6 | 6 |
| 7 #include <set> | 7 #include <set> |
| 8 #include <vector> | 8 #include <vector> |
| 9 | 9 |
| 10 #include "components/payments/payment_request.mojom.h" | 10 #include "components/payments/payment_request.mojom.h" |
| (...skipping 26 matching lines...) Expand all Loading... |
| 37 if (item->amount->value.empty()) { | 37 if (item->amount->value.empty()) { |
| 38 *error_message = "Currency value required"; | 38 *error_message = "Currency value required"; |
| 39 return false; | 39 return false; |
| 40 } | 40 } |
| 41 | 41 |
| 42 if (item->amount->currency != total->amount->currency) { | 42 if (item->amount->currency != total->amount->currency) { |
| 43 *error_message = "Currencies must all be equal"; | 43 *error_message = "Currencies must all be equal"; |
| 44 return false; | 44 return false; |
| 45 } | 45 } |
| 46 | 46 |
| 47 if (item->amount->currency_system.has_value() && | 47 if (item->amount->currency_system.empty()) { |
| 48 item->amount->currency_system.value().empty()) { | |
| 49 *error_message = "Currency system can't be empty"; | 48 *error_message = "Currency system can't be empty"; |
| 50 return false; | 49 return false; |
| 51 } | 50 } |
| 52 | 51 |
| 53 if (!payments::PaymentsValidators::isValidCurrencyCodeFormat( | 52 if (!payments::PaymentsValidators::isValidCurrencyCodeFormat( |
| 54 item->amount->currency, item->amount->currency_system.has_value() | 53 item->amount->currency, item->amount->currency_system, |
| 55 ? item->amount->currency_system.value() | |
| 56 : "", | |
| 57 error_message)) { | 54 error_message)) { |
| 58 return false; | 55 return false; |
| 59 } | 56 } |
| 60 | 57 |
| 61 if (!payments::PaymentsValidators::isValidAmountFormat(item->amount->value, | 58 if (!payments::PaymentsValidators::isValidAmountFormat(item->amount->value, |
| 62 error_message)) { | 59 error_message)) { |
| 63 return false; | 60 return false; |
| 64 } | 61 } |
| 65 return true; | 62 return true; |
| 66 } | 63 } |
| (...skipping 109 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 176 if (!validatePaymentDetailsModifiers(details->modifiers, details->total, | 173 if (!validatePaymentDetailsModifiers(details->modifiers, details->total, |
| 177 error_message)) | 174 error_message)) |
| 178 return false; | 175 return false; |
| 179 } | 176 } |
| 180 if (!PaymentsValidators::isValidErrorMsgFormat(details->error, error_message)) | 177 if (!PaymentsValidators::isValidErrorMsgFormat(details->error, error_message)) |
| 181 return false; | 178 return false; |
| 182 return true; | 179 return true; |
| 183 } | 180 } |
| 184 | 181 |
| 185 } // namespace payments | 182 } // namespace payments |
| OLD | NEW |