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

Side by Side Diff: components/autofill/core/browser/validation.cc

Issue 102843002: Move RemoveChars, ReplaceChars, TrimString, and TruncateUTF8ToByteSize to base namespace. (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src
Patch Set: Created 7 years 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 | Annotate | Revision Log
OLDNEW
1 // Copyright 2013 The Chromium Authors. All rights reserved. 1 // Copyright 2013 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 "components/autofill/core/browser/validation.h" 5 #include "components/autofill/core/browser/validation.h"
6 6
7 #include "base/strings/string_number_conversions.h" 7 #include "base/strings/string_number_conversions.h"
8 #include "base/strings/string_piece.h" 8 #include "base/strings/string_piece.h"
9 #include "base/strings/string_util.h" 9 #include "base/strings/string_util.h"
10 #include "base/strings/utf_string_conversions.h" 10 #include "base/strings/utf_string_conversions.h"
(...skipping 139 matching lines...) Expand 10 before | Expand all | Expand 10 after
150 !state_names::GetNameForAbbreviation(text).empty(); 150 !state_names::GetNameForAbbreviation(text).empty();
151 } 151 }
152 152
153 bool IsValidZip(const base::string16& text) { 153 bool IsValidZip(const base::string16& text) {
154 const base::string16 kZipPattern = ASCIIToUTF16("^\\d{5}(-\\d{4})?$"); 154 const base::string16 kZipPattern = ASCIIToUTF16("^\\d{5}(-\\d{4})?$");
155 return MatchesPattern(text, kZipPattern); 155 return MatchesPattern(text, kZipPattern);
156 } 156 }
157 157
158 bool IsSSN(const string16& text) { 158 bool IsSSN(const string16& text) {
159 string16 number_string; 159 string16 number_string;
160 RemoveChars(text, kSSNSeparators, &number_string); 160 base::RemoveChars(text, kSSNSeparators, &number_string);
161 161
162 // A SSN is of the form AAA-GG-SSSS (A = area number, G = group number, S = 162 // A SSN is of the form AAA-GG-SSSS (A = area number, G = group number, S =
163 // serial number). The validation we do here is simply checking if the area, 163 // serial number). The validation we do here is simply checking if the area,
164 // group, and serial numbers are valid. 164 // group, and serial numbers are valid.
165 // 165 //
166 // Historically, the area number was assigned per state, with the group number 166 // Historically, the area number was assigned per state, with the group number
167 // ascending in an alternating even/odd sequence. With that scheme it was 167 // ascending in an alternating even/odd sequence. With that scheme it was
168 // possible to check for validity by referencing a table that had the highest 168 // possible to check for validity by referencing a table that had the highest
169 // group number assigned for a given area number. (This was something that 169 // group number assigned for a given area number. (This was something that
170 // Chromium never did though, because the "high group" values were constantly 170 // Chromium never did though, because the "high group" values were constantly
(...skipping 40 matching lines...) Expand 10 before | Expand all | Expand 10 after
211 number_string.begin() + 9), 211 number_string.begin() + 9),
212 &serial) 212 &serial)
213 || serial == 0) { 213 || serial == 0) {
214 return false; 214 return false;
215 } 215 }
216 216
217 return true; 217 return true;
218 } 218 }
219 219
220 } // namespace autofill 220 } // namespace autofill
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698