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

Unified Diff: components/autofill/browser/validation.cc

Issue 14148004: [Autofill] Move IsValidState() into validation.h (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src
Patch Set: Created 7 years, 8 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/autofill/browser/validation.cc
diff --git a/components/autofill/browser/validation.cc b/components/autofill/browser/validation.cc
index c5779fb2596e75eb2b08477158bfcdd4bf8a35b1..c9a09f8140d7d7f05ea7d1b42162831eb3407c94 100644
--- a/components/autofill/browser/validation.cc
+++ b/components/autofill/browser/validation.cc
@@ -10,6 +10,7 @@
#include "base/utf_string_conversions.h"
#include "components/autofill/browser/autofill_regexes.h"
#include "components/autofill/browser/credit_card.h"
+#include "components/autofill/browser/state_names.h"
namespace autofill {
@@ -110,9 +111,14 @@ bool IsValidEmailAddress(const base::string16& text) {
return MatchesPattern(text, kEmailPattern);
}
-bool IsValidZip(const base::string16& value) {
+bool IsValidState(const base::string16& text) {
+ return !state_names::GetAbbreviationForName(text).empty() ||
+ !state_names::GetNameForAbbreviation(text).empty();
+}
+
+bool IsValidZip(const base::string16& text) {
const base::string16 kZipPattern = ASCIIToUTF16("^\\d{5}(-\\d{4})?$");
- return MatchesPattern(value, kZipPattern);
+ return MatchesPattern(text, kZipPattern);
}
} // namespace autofill
« components/autofill/browser/form_group.cc ('K') | « components/autofill/browser/validation.h ('k') | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698