| OLD | NEW |
| 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 Loading... |
| 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 Loading... |
| 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 |
| OLD | NEW |