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 "chrome/browser/autofill/validation.h" |
6 | 6 |
7 #include "base/string_util.h" | 7 #include "base/string_util.h" |
8 #include "chrome/browser/autofill/credit_card.h" | 8 #include "chrome/browser/autofill/credit_card.h" |
9 | 9 |
10 namespace autofill { | 10 namespace autofill { |
(...skipping 27 matching lines...) Expand all Loading... |
38 sum += digit / 10 + digit % 10; | 38 sum += digit / 10 + digit % 10; |
39 } else { | 39 } else { |
40 sum += digit; | 40 sum += digit; |
41 } | 41 } |
42 odd = !odd; | 42 odd = !odd; |
43 } | 43 } |
44 | 44 |
45 return (sum % 10) == 0; | 45 return (sum % 10) == 0; |
46 } | 46 } |
47 | 47 |
| 48 bool IsValidCreditCardSecurityCode(const string16& text) { |
| 49 if (text.size() < 3U || text.size() > 4U) |
| 50 return false; |
| 51 |
| 52 for (string16::const_iterator iter = text.begin(); |
| 53 iter != text.end(); |
| 54 ++iter) { |
| 55 if (!IsAsciiDigit(*iter)) |
| 56 return false; |
| 57 } |
| 58 return true; |
| 59 } |
| 60 |
48 } // namespace autofill | 61 } // namespace autofill |
OLD | NEW |