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

Side by Side Diff: components/payments/payments_validators.cc

Issue 2373103002: [Web Payments] Common Payments validation (Closed)
Patch Set: Deps 2 Created 4 years, 1 month 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
(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 #include "components/payments/payments_validators.h"
6
7 namespace payments {
8
9 // We limit the maximum length of the currency code to 2048 bytes for security
10 // reasons.
11 static const int maxCurrencyCodeLength = 2048;
12
13 bool PaymentsValidators::isValidCurrencyCodeFormat(
14 const std::string& code,
15 std::string* optionalErrorMessage) {
16 if (code.size() <= maxCurrencyCodeLength)
17 return true;
18
19 if (optionalErrorMessage)
20 *optionalErrorMessage =
21 "The currency code should be at most 2048 characters long";
22
23 return false;
24 }
25
26 bool PaymentsValidators::isValidAmountFormat(
27 const std::string& amount,
28 std::string* optionalErrorMessage) {
29 // if (ScriptRegexp("^-?[0-9]+(\\.[0-9]+)?$",
please use gerrit instead 2016/10/28 18:38:58 Can you use https://cs.chromium.org/chromium/src/t
Kevin Bailey 2016/10/28 20:53:05 Done. (Sorry if I nuked it.) But there was a probl
please use gerrit instead 2016/10/31 13:17:33 Seems that "re2" dependency was added to component
Kevin Bailey 2016/10/31 14:10:03 Ya, it required the full path.
30 // TextCaseSensitive).match(amount) == 0)
31 // return true;
32
33 if (optionalErrorMessage)
34 *optionalErrorMessage = "'" + amount + "' is not a valid amount format";
35
36 return false;
37 }
38
39 } // namespace payments
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698