summaryrefslogtreecommitdiff
path: root/chromium/components/autofill/core/browser/validation.cc
diff options
context:
space:
mode:
authorAllan Sandfeld Jensen <allan.jensen@qt.io>2017-07-12 14:07:37 +0200
committerAllan Sandfeld Jensen <allan.jensen@qt.io>2017-07-17 10:29:26 +0000
commitec02ee4181c49b61fce1c8fb99292dbb8139cc90 (patch)
tree25cde714b2b71eb639d1cd53f5a22e9ba76e14ef /chromium/components/autofill/core/browser/validation.cc
parentbb09965444b5bb20b096a291445170876225268d (diff)
downloadqtwebengine-chromium-ec02ee4181c49b61fce1c8fb99292dbb8139cc90.tar.gz
BASELINE: Update Chromium to 59.0.3071.134
Change-Id: Id02ef6fb2204c5fd21668a1c3e6911c83b17585a Reviewed-by: Alexandru Croitor <alexandru.croitor@qt.io>
Diffstat (limited to 'chromium/components/autofill/core/browser/validation.cc')
-rw-r--r--chromium/components/autofill/core/browser/validation.cc22
1 files changed, 20 insertions, 2 deletions
diff --git a/chromium/components/autofill/core/browser/validation.cc b/chromium/components/autofill/core/browser/validation.cc
index d18ccbab5cf..e7237f7b3b7 100644
--- a/chromium/components/autofill/core/browser/validation.cc
+++ b/chromium/components/autofill/core/browser/validation.cc
@@ -13,7 +13,9 @@
#include "base/strings/utf_string_conversions.h"
#include "base/time/time.h"
#include "components/autofill/core/browser/autofill_data_util.h"
+#include "components/autofill/core/browser/autofill_regex_constants.h"
#include "components/autofill/core/browser/credit_card.h"
+#include "components/autofill/core/browser/phone_number_i18n.h"
#include "components/autofill/core/browser/state_names.h"
#include "components/autofill/core/common/autofill_clock.h"
#include "components/autofill/core/common/autofill_regexes.h"
@@ -94,8 +96,7 @@ bool IsValidCreditCardNumber(const base::string16& text) {
bool IsValidCreditCardSecurityCode(const base::string16& code,
const base::StringPiece card_type) {
- size_t required_length = card_type == kAmericanExpressCard ? 4 : 3;
- return code.length() == required_length &&
+ return code.length() == GetCvcLengthForCardType(card_type) &&
base::ContainsOnlyChars(code, base::ASCIIToUTF16("0123456789"));
}
@@ -137,6 +138,12 @@ bool IsValidState(const base::string16& text) {
!state_names::GetNameForAbbreviation(text).empty();
}
+bool IsValidPhoneNumber(const base::string16& text,
+ const std::string& country_code) {
+ i18n::PhoneObject phone_number(text, country_code);
+ return phone_number.IsValidNumber();
+}
+
bool IsValidZip(const base::string16& text) {
const base::string16 kZipPattern = base::ASCIIToUTF16("^\\d{5}(-\\d{4})?$");
return MatchesPattern(text, kZipPattern);
@@ -308,4 +315,15 @@ bool IsValidForType(const base::string16& value,
return false;
}
+size_t GetCvcLengthForCardType(const base::StringPiece card_type) {
+ if (card_type == kAmericanExpressCard)
+ return AMEX_CVC_LENGTH;
+
+ return GENERAL_CVC_LENGTH;
+}
+
+bool IsUPIVirtualPaymentAddress(const base::string16& value) {
+ return MatchesPattern(value, base::ASCIIToUTF16(kUPIVirtualPaymentAddressRe));
+}
+
} // namespace autofill