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

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

Issue 2611863002: Refactors cvc and expiration date validation in CC upload logic as well as unmask prompt. (Closed)
Patch Set: Addressed comments Created 3 years, 11 months 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
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 #ifndef COMPONENTS_AUTOFILL_CORE_BROWSER_VALIDATION_H_ 5 #ifndef COMPONENTS_AUTOFILL_CORE_BROWSER_VALIDATION_H_
6 #define COMPONENTS_AUTOFILL_CORE_BROWSER_VALIDATION_H_ 6 #define COMPONENTS_AUTOFILL_CORE_BROWSER_VALIDATION_H_
7 7
8 #include "base/strings/string16.h" 8 #include "base/strings/string16.h"
9 #include "base/strings/string_piece.h"
9 10
10 namespace base { 11 namespace base {
11 class Time; 12 class Time;
12 } // namespace base 13 } // namespace base
13 14
14 namespace autofill { 15 namespace autofill {
15 16
16 // Returns true if |year| and |month| describe a date later than |now|. 17 // Returns true if |year| and |month| describe a date later than |now|.
17 // |year| must have 4 digits. 18 // |year| must have 4 digits.
18 bool IsValidCreditCardExpirationDate(int year, 19 bool IsValidCreditCardExpirationDate(int year,
19 int month, 20 int month,
20 const base::Time& now); 21 const base::Time& now);
21 22
22 // Returns true if |text| looks like a valid credit card number. 23 // Returns true if |text| looks like a valid credit card number.
23 // Uses the Luhn formula to validate the number. 24 // Uses the Luhn formula to validate the number.
24 bool IsValidCreditCardNumber(const base::string16& text); 25 bool IsValidCreditCardNumber(const base::string16& text);
25 26
26 // Returns true if |text| looks like a valid credit card security code.
27 bool IsValidCreditCardSecurityCode(const base::string16& text);
28
29 // Returns true if |code| looks like a valid credit card security code 27 // Returns true if |code| looks like a valid credit card security code
30 // for the type of credit card designated by |number|. 28 // for the given credit card type.
31 bool IsValidCreditCardSecurityCode(const base::string16& code, 29 bool IsValidCreditCardSecurityCode(const base::string16& code,
32 const base::string16& number); 30 const base::StringPiece card_type);
33 31
34 // Returns true if |text| looks like a valid e-mail address. 32 // Returns true if |text| looks like a valid e-mail address.
35 bool IsValidEmailAddress(const base::string16& text); 33 bool IsValidEmailAddress(const base::string16& text);
36 34
37 // Returns true if |text| is a valid US state name or abbreviation. It is 35 // Returns true if |text| is a valid US state name or abbreviation. It is
38 // case insensitive. Valid for US states only. 36 // case insensitive. Valid for US states only.
39 bool IsValidState(const base::string16& text); 37 bool IsValidState(const base::string16& text);
40 38
41 // Returns true if |text| looks like a valid zip code. 39 // Returns true if |text| looks like a valid zip code.
42 // Valid for US zip codes only. 40 // Valid for US zip codes only.
43 bool IsValidZip(const base::string16& text); 41 bool IsValidZip(const base::string16& text);
44 42
45 // Returns true if |text| looks like an SSN, with or without separators. 43 // Returns true if |text| looks like an SSN, with or without separators.
46 bool IsSSN(const base::string16& text); 44 bool IsSSN(const base::string16& text);
47 45
48 } // namespace autofill 46 } // namespace autofill
49 47
50 #endif // COMPONENTS_AUTOFILL_CORE_BROWSER_VALIDATION_H_ 48 #endif // COMPONENTS_AUTOFILL_CORE_BROWSER_VALIDATION_H_
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698