Chromium Code Reviews| OLD | NEW | 
|---|---|
| (Empty) | |
| 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 | |
| 3 // found in the LICENSE file. | |
| 4 | |
| 5 #ifndef COMPONENTS_PAYMENTS_PAYMENTS_VALIDATORS_H_ | |
| 6 #define COMPONENTS_PAYMENTS_PAYMENTS_VALIDATORS_H_ | |
| 7 | |
| 8 #include <string> | |
| 9 | |
| 10 #include "components/payments/payment_request.mojom.h" | |
| 11 | |
| 12 namespace payments { | |
| 13 | |
| 14 class PaymentsValidators { | |
| 15 public: | |
| 16 // The most common identifiers are three-letter alphabetic codes as defined by | |
| 17 // [ISO4217] (for example, "USD" for US Dollars) | |
| 18 // however any string of at most 2048 characters is considered valid. Returns | |
| 19 // false if currency |code| is too long (greater than 2048). | |
| 20 static bool isValidCurrencyCodeFormat(const std::string& code, | |
| 21 std::string* optionalErrorMessage); | |
| 22 | |
| 23 // Returns true if |amount| is a valid currency code as defined in ISO 20022 | |
| 24 // CurrencyAnd30Amount. | |
| 25 static bool isValidAmountFormat(const std::string& amount, | |
| 26 std::string* optionalErrorMessage); | |
| 27 | |
| 
 
please use gerrit instead
2016/10/27 17:14:25
The methods below are not relevant for PaymentDeta
 
Kevin Bailey
2016/10/27 22:17:53
Done.
 
 | |
| 28 // Returns true if |code| is a valid ISO 3166 country code. | |
| 29 static bool isValidCountryCodeFormat(const std::string& code, | |
| 30 std::string* optionalErrorMessage); | |
| 31 | |
| 32 // Returns true if |code| is a valid ISO 639 language code. | |
| 33 static bool isValidLanguageCodeFormat(const std::string& code, | |
| 34 std::string* optionalErrorMessage); | |
| 35 | |
| 36 // Returns true if |code| is a valid ISO 15924 script code. | |
| 37 static bool isValidScriptCodeFormat(const std::string& code, | |
| 38 std::string* optionalErrorMessage); | |
| 39 | |
| 40 // Returns true if the payment address is valid: | |
| 41 // - Has a valid region code | |
| 42 // - Has a valid language code, if any. | |
| 43 // - Has a valid script code, if any. | |
| 44 // A script code should be present only if language code is present. | |
| 45 static bool isValidShippingAddress(const blink::mojom::PaymentAddressPtr&, | |
| 46 std::string* optionalErrorMessage); | |
| 47 }; | |
| 48 | |
| 49 } // namespace payments | |
| 50 | |
| 51 #endif // COMPONENTS_PAYMENTS_PAYMENTS_VALIDATORS_H_ | |
| OLD | NEW |