Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(49)

Side by Side Diff: components/payments/content/payments_validators.h

Issue 2713033004: Layered component for web payments (Closed)
Patch Set: Rebase Created 3 years, 9 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View unified diff | Download patch
OLDNEW
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 #ifndef COMPONENTS_PAYMENTS_PAYMENTS_VALIDATORS_H_ 5 #ifndef COMPONENTS_PAYMENTS_CONTENT_PAYMENTS_VALIDATORS_H_
6 #define COMPONENTS_PAYMENTS_PAYMENTS_VALIDATORS_H_ 6 #define COMPONENTS_PAYMENTS_CONTENT_PAYMENTS_VALIDATORS_H_
7 7
8 #include <string> 8 #include <string>
9 9
10 #include "components/payments/payment_request.mojom.h" 10 #include "base/macros.h"
11 #include "components/payments/content/payment_request.mojom.h"
11 12
12 namespace payments { 13 namespace payments {
13 14
14 class PaymentsValidators { 15 class PaymentsValidators {
15 public: 16 public:
16 // The most common identifiers are three-letter alphabetic codes as 17 // The most common identifiers are three-letter alphabetic codes as
17 // defined by [ISO4217] (for example, "USD" for US Dollars). |system| is 18 // defined by [ISO4217] (for example, "USD" for US Dollars). |system| is
18 // a URL that indicates the currency system that the currency identifier 19 // 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 // 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 // that currency is defined by [[ISO4217]], however any string of at most
21 // 2048 characters is considered valid in other currencySystem. Returns 22 // 2048 characters is considered valid in other currencySystem. Returns
22 // false if currency |code| is too long (greater than 2048). 23 // false if currency |code| is too long (greater than 2048).
23 static bool isValidCurrencyCodeFormat(const std::string& code, 24 static bool isValidCurrencyCodeFormat(const std::string& code,
24 const std::string& system, 25 const std::string& system,
25 std::string* optionalErrorMessage); 26 std::string* optional_error_message);
26 27
27 // Returns true if |amount| is a valid currency code as defined in ISO 20022 28 // Returns true if |amount| is a valid currency code as defined in ISO 20022
28 // CurrencyAnd30Amount. 29 // CurrencyAnd30Amount.
29 static bool isValidAmountFormat(const std::string& amount, 30 static bool isValidAmountFormat(const std::string& amount,
30 std::string* optionalErrorMessage); 31 std::string* optional_error_message);
31 32
32 // Returns true if |code| is a valid ISO 3166 country code. 33 // Returns true if |code| is a valid ISO 3166 country code.
33 static bool isValidCountryCodeFormat(const std::string& code, 34 static bool isValidCountryCodeFormat(const std::string& code,
34 std::string* optionalErrorMessage); 35 std::string* optional_error_message);
35 36
36 // Returns true if |code| is a valid ISO 639 language code. 37 // Returns true if |code| is a valid ISO 639 language code.
37 static bool isValidLanguageCodeFormat(const std::string& code, 38 static bool isValidLanguageCodeFormat(const std::string& code,
38 std::string* optionalErrorMessage); 39 std::string* optional_error_message);
39 40
40 // Returns true if |code| is a valid ISO 15924 script code. 41 // Returns true if |code| is a valid ISO 15924 script code.
41 static bool isValidScriptCodeFormat(const std::string& code, 42 static bool isValidScriptCodeFormat(const std::string& code,
42 std::string* optionalErrorMessage); 43 std::string* optional_error_message);
43 44
44 // Returns true if the payment address is valid: 45 // Returns true if the payment address is valid:
45 // - Has a valid region code 46 // - Has a valid region code
46 // - Has a valid language code, if any. 47 // - Has a valid language code, if any.
47 // - Has a valid script code, if any. 48 // - Has a valid script code, if any.
48 // A script code should be present only if language code is present. 49 // A script code should be present only if language code is present.
49 static bool isValidShippingAddress(const mojom::PaymentAddressPtr&, 50 static bool isValidShippingAddress(const mojom::PaymentAddressPtr& address,
50 std::string* optionalErrorMessage); 51 std::string* optional_error_message);
51 52
52 // Returns false if |error| is too long (greater than 2048). 53 // Returns false if |error| is too long (greater than 2048).
53 static bool isValidErrorMsgFormat(const std::string& code, 54 static bool isValidErrorMsgFormat(const std::string& code,
54 std::string* optionalErrorMessage); 55 std::string* optional_error_message);
56
57 private:
58 DISALLOW_IMPLICIT_CONSTRUCTORS(PaymentsValidators);
55 }; 59 };
56 60
57 } // namespace payments 61 } // namespace payments
58 62
59 #endif // COMPONENTS_PAYMENTS_PAYMENTS_VALIDATORS_H_ 63 #endif // COMPONENTS_PAYMENTS_CONTENT_PAYMENTS_VALIDATORS_H_
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698