Chromium Code Reviews| Index: components/autofill/core/browser/validation.cc |
| diff --git a/components/autofill/core/browser/validation.cc b/components/autofill/core/browser/validation.cc |
| index b784a2697937f8e9586e1292376ca73cf164481a..6d2527df3417dc044fdaecf183f7fd8e77eae3f8 100644 |
| --- a/components/autofill/core/browser/validation.cc |
| +++ b/components/autofill/core/browser/validation.cc |
| @@ -90,22 +90,20 @@ bool IsValidCreditCardNumber(const base::string16& text) { |
| bool IsValidCreditCardSecurityCode(const base::string16& text) { |
|
Mathieu
2017/01/04 18:20:17
From quick codesearch, looks like this is unused.
Moe
2017/01/04 18:31:28
Looks like it's being used in https://cs.chromium.
Mathieu
2017/01/04 19:12:37
Yes but I would say the test doesn't count. Let's
Moe
2017/01/05 05:25:20
Oh i see. My bad. Removed the unused functions and
|
| if (text.size() < 3U || text.size() > 4U) |
| return false; |
| - |
| - for (const base::char16& it : text) { |
| - if (!base::IsAsciiDigit(it)) |
| - return false; |
| - } |
| - return true; |
| + return base::ContainsOnlyChars(text, base::ASCIIToUTF16("0123456789"));; |
|
Mathieu
2017/01/04 18:20:17
nit: double ;
Moe
2017/01/04 18:31:28
Done.
|
| } |
| bool IsValidCreditCardSecurityCode(const base::string16& code, |
| const base::string16& number) { |
| - const char* const type = CreditCard::GetCreditCardType(number); |
| - size_t required_length = 3; |
| - if (type == kAmericanExpressCard) |
| - required_length = 4; |
| + const char* const card_type = CreditCard::GetCreditCardType(number); |
| + return IsValidCreditCardSecurityCode(code, card_type); |
| +} |
| - return code.length() == required_length; |
| +bool IsValidCreditCardSecurityCode(const base::string16& code, |
| + const base::StringPiece card_type) { |
| + size_t required_length = card_type == kAmericanExpressCard ? 4 : 3; |
| + return code.length() == required_length && |
| + base::ContainsOnlyChars(code, base::ASCIIToUTF16("0123456789")); |
| } |
| bool IsValidEmailAddress(const base::string16& text) { |