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 | |
| 17 // defined by [ISO4217] (for example, "USD" for US Dollars). |system| is | |
| 18 // a URL that indicates the currency system that the currency identifier | |
| 19 // belongs to. By default, the value is urn:iso:std:iso:4217 indicating | |
| 20 // that currency is defined by [[ISO4217]], however any string of at most | |
| 21 // 2048 characters is considered valid in other currencySystem. Returns | |
| 22 // false if currency |code| is too long (greater than 2048). | |
| 23 static bool isValidCurrencyCodeFormat(const std::string& code, | |
| 24 const std::string& system, | |
| 25 std::string* optionalErrorMessage); | |
| 26 | |
| 27 // Returns true if |amount| is a valid currency code as defined in ISO 20022 | |
| 28 // CurrencyAnd30Amount. | |
| 29 static bool isValidAmountFormat(const std::string& amount, | |
| 30 std::string* optionalErrorMessage); | |
| 31 | |
| 32 // Returns true if |code| is a valid ISO 3166 country code. | |
| 33 static bool isValidCountryCodeFormat(const std::string& code, | |
| 34 std::string* optionalErrorMessage); | |
| 35 | |
| 36 // Returns true if |code| is a valid ISO 639 language code. | |
| 37 static bool isValidLanguageCodeFormat(const std::string& code, | |
| 38 std::string* optionalErrorMessage); | |
| 39 | |
| 40 // Returns true if |code| is a valid ISO 15924 script code. | |
| 41 static bool isValidScriptCodeFormat(const std::string& code, | |
| 42 std::string* optionalErrorMessage); | |
| 43 | |
| 44 // Returns true if the payment address is valid: | |
| 45 // - Has a valid region code | |
| 46 // - Has a valid language code, if any. | |
| 47 // - Has a valid script code, if any. | |
| 48 // A script code should be present only if language code is present. | |
| 49 static bool isValidShippingAddress(const blink::mojom::PaymentAddressPtr&, | |
| 50 std::string* optionalErrorMessage); | |
| 
 
please use gerrit instead
2016/11/01 14:20:03
No need for isValidCountryCodeFormat, isValidLangu
 
Kevin Bailey
2016/11/01 15:32:13
Your tests wanted them, and the new guys may not k
 
 | |
| 51 | |
| 52 // Returns false if |error| is too long (greater than 2048). | |
| 53 static bool isValidErrorMsgFormat(const std::string& code, | |
| 54 std::string* optionalErrorMessage); | |
| 55 }; | |
| 56 | |
| 57 } // namespace payments | |
| 58 | |
| 59 #endif // COMPONENTS_PAYMENTS_PAYMENTS_VALIDATORS_H_ | |
| OLD | NEW |