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

Unified Diff: components/payments/payments_validators.h

Issue 2373103002: [Web Payments] Common Payments validation (Closed)
Patch Set: Split off moving Mojo file 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 side-by-side diff with in-line comments
Download patch
Index: components/payments/payments_validators.h
diff --git a/components/payments/payments_validators.h b/components/payments/payments_validators.h
new file mode 100644
index 0000000000000000000000000000000000000000..ceb301f20b907a2e37ee710a7b41e030714f662f
--- /dev/null
+++ b/components/payments/payments_validators.h
@@ -0,0 +1,51 @@
+// Copyright 2016 The Chromium Authors. All rights reserved.
+// Use of this source code is governed by a BSD-style license that can be
+// found in the LICENSE file.
+
+#ifndef COMPONENTS_PAYMENTS_PAYMENTS_VALIDATORS_H_
+#define COMPONENTS_PAYMENTS_PAYMENTS_VALIDATORS_H_
+
+#include <string>
+
+#include "components/payments/payment_request.mojom.h"
+
+namespace payments {
+
+class PaymentsValidators {
+ public:
+ // The most common identifiers are three-letter alphabetic codes as defined by
+ // [ISO4217] (for example, "USD" for US Dollars)
+ // however any string of at most 2048 characters is considered valid. Returns
+ // false if currency |code| is too long (greater than 2048).
+ static bool isValidCurrencyCodeFormat(const std::string& code,
+ std::string* optionalErrorMessage);
+
+ // Returns true if |amount| is a valid currency code as defined in ISO 20022
+ // CurrencyAnd30Amount.
+ static bool isValidAmountFormat(const std::string& amount,
+ std::string* optionalErrorMessage);
+
please use gerrit instead 2016/10/27 17:14:25 The methods below are not relevant for PaymentDeta
Kevin Bailey 2016/10/27 22:17:53 Done.
+ // Returns true if |code| is a valid ISO 3166 country code.
+ static bool isValidCountryCodeFormat(const std::string& code,
+ std::string* optionalErrorMessage);
+
+ // Returns true if |code| is a valid ISO 639 language code.
+ static bool isValidLanguageCodeFormat(const std::string& code,
+ std::string* optionalErrorMessage);
+
+ // Returns true if |code| is a valid ISO 15924 script code.
+ static bool isValidScriptCodeFormat(const std::string& code,
+ std::string* optionalErrorMessage);
+
+ // Returns true if the payment address is valid:
+ // - Has a valid region code
+ // - Has a valid language code, if any.
+ // - Has a valid script code, if any.
+ // A script code should be present only if language code is present.
+ static bool isValidShippingAddress(const blink::mojom::PaymentAddressPtr&,
+ std::string* optionalErrorMessage);
+};
+
+} // namespace payments
+
+#endif // COMPONENTS_PAYMENTS_PAYMENTS_VALIDATORS_H_

Powered by Google App Engine
This is Rietveld 408576698