OLD | NEW |
1 // Copyright (c) 2013 The Chromium Authors. All rights reserved. | 1 // Copyright (c) 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 "chrome/browser/autofill/validation.h" | 5 #include "components/autofill/browser/validation.h" |
6 | 6 |
7 #include "base/string_util.h" | 7 #include "base/string_util.h" |
8 #include "base/utf_string_conversions.h" | 8 #include "base/utf_string_conversions.h" |
9 #include "chrome/browser/autofill/autofill_regexes.h" | 9 #include "components/autofill/browser/autofill_regexes.h" |
10 #include "chrome/browser/autofill/credit_card.h" | 10 #include "components/autofill/browser/credit_card.h" |
11 | 11 |
12 namespace autofill { | 12 namespace autofill { |
13 | 13 |
14 bool IsValidCreditCardNumber(const string16& text) { | 14 bool IsValidCreditCardNumber(const string16& text) { |
15 string16 number = CreditCard::StripSeparators(text); | 15 string16 number = CreditCard::StripSeparators(text); |
16 | 16 |
17 // Credit card numbers are at most 19 digits in length [1]. 12 digits seems to | 17 // Credit card numbers are at most 19 digits in length [1]. 12 digits seems to |
18 // be a fairly safe lower-bound [2]. | 18 // be a fairly safe lower-bound [2]. |
19 // [1] http://www.merriampark.com/anatomycc.htm | 19 // [1] http://www.merriampark.com/anatomycc.htm |
20 // [2] http://en.wikipedia.org/wiki/Bank_card_number | 20 // [2] http://en.wikipedia.org/wiki/Bank_card_number |
(...skipping 46 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
67 "[a-zA-Z0-9-]+(?:\\.[a-zA-Z0-9-]+)*$"); | 67 "[a-zA-Z0-9-]+(?:\\.[a-zA-Z0-9-]+)*$"); |
68 return MatchesPattern(text, kEmailPattern); | 68 return MatchesPattern(text, kEmailPattern); |
69 } | 69 } |
70 | 70 |
71 bool IsValidZip(const string16& value) { | 71 bool IsValidZip(const string16& value) { |
72 const string16 kZipPattern = ASCIIToUTF16("^\\d{5}(-\\d{4})?$"); | 72 const string16 kZipPattern = ASCIIToUTF16("^\\d{5}(-\\d{4})?$"); |
73 return MatchesPattern(value, kZipPattern); | 73 return MatchesPattern(value, kZipPattern); |
74 } | 74 } |
75 | 75 |
76 } // namespace autofill | 76 } // namespace autofill |
OLD | NEW |