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

Side by Side Diff: third_party/WebKit/Source/modules/payments/PaymentsValidators.cpp

Issue 2355463002: [PaymentReqeust] Add error message in PaymentDetails. (in blink side) (Closed)
Patch Set: rebase from origin Created 4 years, 2 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 #include "modules/payments/PaymentsValidators.h" 5 #include "modules/payments/PaymentsValidators.h"
6 6
7 #include "bindings/core/v8/ScriptRegexp.h" 7 #include "bindings/core/v8/ScriptRegexp.h"
8 #include "wtf/text/StringImpl.h" 8 #include "wtf/text/StringImpl.h"
9 9
10 namespace blink { 10 namespace blink {
11 11
12 // We limit the maximum length of the currency code to 2048 bytes for security r easons. 12 // We limit the maximum length of string to 2048 bytes for security reasons.
13 static const int maxCurrencyCodeLength = 2048; 13 static const int maxiumStringLength = 2048;
14 14
15 bool PaymentsValidators::isValidCurrencyCodeFormat(const String& code, String* o ptionalErrorMessage) 15 bool PaymentsValidators::isValidCurrencyCodeFormat(const String& code, String* o ptionalErrorMessage)
16 { 16 {
17 if (code.length() <= maxCurrencyCodeLength) 17 if (code.length() <= maxiumStringLength)
18 return true; 18 return true;
19 19
20 if (optionalErrorMessage) 20 if (optionalErrorMessage)
21 *optionalErrorMessage = "The currency code should be at most 2048 charac ters long"; 21 *optionalErrorMessage = "The currency code should be at most 2048 charac ters long";
22 22
23 return false; 23 return false;
24 } 24 }
25 25
26 bool PaymentsValidators::isValidAmountFormat(const String& amount, String* optio nalErrorMessage) 26 bool PaymentsValidators::isValidAmountFormat(const String& amount, String* optio nalErrorMessage)
27 { 27 {
(...skipping 53 matching lines...) Expand 10 before | Expand all | Expand 10 after
81 if (address->language_code.isEmpty() && !address->script_code.isEmpty()) { 81 if (address->language_code.isEmpty() && !address->script_code.isEmpty()) {
82 if (optionalErrorMessage) 82 if (optionalErrorMessage)
83 *optionalErrorMessage = "If language code is empty, then script code should also be empty"; 83 *optionalErrorMessage = "If language code is empty, then script code should also be empty";
84 84
85 return false; 85 return false;
86 } 86 }
87 87
88 return true; 88 return true;
89 } 89 }
90 90
91 bool PaymentsValidators::isValidErrorMsgFormat(const String& error, String* opti onalErrorMessage)
92 {
93 if (error.length() <= maxiumStringLength)
94 return true;
95
96 if (optionalErrorMessage)
97 *optionalErrorMessage = "Error message should be at most 2048 characters long";
98
99 return false;
100 }
101
91 } // namespace blink 102 } // namespace blink
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698