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 #ifndef PaymentsValidators_h | 5 #ifndef PaymentsValidators_h |
6 #define PaymentsValidators_h | 6 #define PaymentsValidators_h |
7 | 7 |
8 #include "modules/ModulesExport.h" | 8 #include "modules/ModulesExport.h" |
9 #include "public/platform/modules/payments/payment_request.mojom-blink.h" | 9 #include "public/platform/modules/payments/payment_request.mojom-blink.h" |
10 #include "wtf/Allocator.h" | 10 #include "wtf/Allocator.h" |
11 #include "wtf/text/WTFString.h" | 11 #include "wtf/text/WTFString.h" |
12 | 12 |
13 namespace blink { | 13 namespace blink { |
14 | 14 |
15 class MODULES_EXPORT PaymentsValidators final { | 15 class MODULES_EXPORT PaymentsValidators final { |
16 STATIC_ONLY(PaymentsValidators); | 16 STATIC_ONLY(PaymentsValidators); |
17 | 17 |
18 public: | 18 public: |
19 // Returns true if |code| is a valid ISO 4217 currency code. | 19 // The most common identifiers are three-letter alphabetic codes as defined by [ISO4217] (for example, "USD" for US Dollars) |
20 // however any string is considered valid. Returns false if currency |code| is too long ( greater than 2048). | |
please use gerrit instead
2016/08/25 16:47:38
No space after (
pals
2016/08/26 07:20:26
Done.
| |
20 static bool isValidCurrencyCodeFormat(const String& code, String* optionalEr rorMessage); | 21 static bool isValidCurrencyCodeFormat(const String& code, String* optionalEr rorMessage); |
21 | 22 |
22 // Returns true if |amount| is a valid currency code as defined in ISO 20022 CurrencyAnd30Amount. | 23 // Returns true if |amount| is a valid currency code as defined in ISO 20022 CurrencyAnd30Amount. |
23 static bool isValidAmountFormat(const String& amount, String* optionalErrorM essage); | 24 static bool isValidAmountFormat(const String& amount, String* optionalErrorM essage); |
24 | 25 |
25 // Returns true if |code| is a valid ISO 3166 country code. | 26 // Returns true if |code| is a valid ISO 3166 country code. |
26 static bool isValidCountryCodeFormat(const String& code, String* optionalErr orMessage); | 27 static bool isValidCountryCodeFormat(const String& code, String* optionalErr orMessage); |
27 | 28 |
28 // Returns true if |code| is a valid ISO 639 language code. | 29 // Returns true if |code| is a valid ISO 639 language code. |
29 static bool isValidLanguageCodeFormat(const String& code, String* optionalEr rorMessage); | 30 static bool isValidLanguageCodeFormat(const String& code, String* optionalEr rorMessage); |
30 | 31 |
31 // Returns true if |code| is a valid ISO 15924 script code. | 32 // Returns true if |code| is a valid ISO 15924 script code. |
32 static bool isValidScriptCodeFormat(const String& code, String* optionalErro rMessage); | 33 static bool isValidScriptCodeFormat(const String& code, String* optionalErro rMessage); |
33 | 34 |
34 // Returns true if the payment address is valid: | 35 // Returns true if the payment address is valid: |
35 // - Has a valid region code | 36 // - Has a valid region code |
36 // - Has a valid language code, if any. | 37 // - Has a valid language code, if any. |
37 // - Has a valid script code, if any. | 38 // - Has a valid script code, if any. |
38 // A script code should be present only if language code is present. | 39 // A script code should be present only if language code is present. |
39 static bool isValidShippingAddress(const mojom::blink::PaymentAddressPtr&, S tring* optionalErrorMessage); | 40 static bool isValidShippingAddress(const mojom::blink::PaymentAddressPtr&, S tring* optionalErrorMessage); |
40 }; | 41 }; |
41 | 42 |
42 } // namespace blink | 43 } // namespace blink |
43 | 44 |
44 #endif // PaymentsValidators_h | 45 #endif // PaymentsValidators_h |
OLD | NEW |