| 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 #ifndef COMPONENTS_AUTOFILL_BROWSER_VALIDATION_H_ | 5 #ifndef COMPONENTS_AUTOFILL_BROWSER_VALIDATION_H_ |
| 6 #define COMPONENTS_AUTOFILL_BROWSER_VALIDATION_H_ | 6 #define COMPONENTS_AUTOFILL_BROWSER_VALIDATION_H_ |
| 7 | 7 |
| 8 #include "base/string16.h" | 8 #include "base/string16.h" |
| 9 #include "components/autofill/common/autofill_export.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(const base::string16& year, | 19 bool AUTOFILL_EXPORT IsValidCreditCardExpirationDate( |
| 19 const base::string16& month, | 20 const base::string16& year, |
| 20 const base::Time& now); | 21 const base::string16& month, |
| 22 const base::Time& now); |
| 21 | 23 |
| 22 // Returns true if |text| looks like a valid credit card number. | 24 // Returns true if |text| looks like a valid credit card number. |
| 23 // Uses the Luhn formula to validate the number. | 25 // Uses the Luhn formula to validate the number. |
| 24 bool IsValidCreditCardNumber(const base::string16& text); | 26 bool AUTOFILL_EXPORT IsValidCreditCardNumber(const base::string16& text); |
| 25 | 27 |
| 26 // Returns true if |text| looks like a valid credit card security code. | 28 // Returns true if |text| looks like a valid credit card security code. |
| 27 bool IsValidCreditCardSecurityCode(const base::string16& text); | 29 bool AUTOFILL_EXPORT IsValidCreditCardSecurityCode(const base::string16& text); |
| 28 | 30 |
| 29 // Returns true if |code| looks like a valid credit card security code | 31 // Returns true if |code| looks like a valid credit card security code |
| 30 // for the type of credit card designated by |number|. | 32 // for the type of credit card designated by |number|. |
| 31 bool IsValidCreditCardSecurityCode(const base::string16& code, | 33 bool AUTOFILL_EXPORT IsValidCreditCardSecurityCode( |
| 32 const base::string16& number); | 34 const base::string16& code, |
| 35 const base::string16& number); |
| 33 | 36 |
| 34 // Returns true if |text| looks like a valid e-mail address. | 37 // Returns true if |text| looks like a valid e-mail address. |
| 35 bool IsValidEmailAddress(const base::string16& text); | 38 bool AUTOFILL_EXPORT IsValidEmailAddress(const base::string16& text); |
| 36 | 39 |
| 37 // Returns true if |text| is a valid US state name or abbreviation. It is | 40 // Returns true if |text| is a valid US state name or abbreviation. It is |
| 38 // case insensitive. Valid for US states only. | 41 // case insensitive. Valid for US states only. |
| 39 bool IsValidState(const base::string16& text); | 42 bool IsValidState(const base::string16& text); |
| 40 | 43 |
| 41 // Returns true if |text| looks like a valid zip code. | 44 // Returns true if |text| looks like a valid zip code. |
| 42 // Valid for US zip codes only. | 45 // Valid for US zip codes only. |
| 43 bool IsValidZip(const base::string16& text); | 46 bool AUTOFILL_EXPORT IsValidZip(const base::string16& text); |
| 44 | 47 |
| 45 } // namespace autofill | 48 } // namespace autofill |
| 46 | 49 |
| 47 #endif // COMPONENTS_AUTOFILL_BROWSER_VALIDATION_H_ | 50 #endif // COMPONENTS_AUTOFILL_BROWSER_VALIDATION_H_ |
| OLD | NEW |