| OLD | NEW |
| 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 #include "base/strings/string_piece.h" |
| 10 #include "components/autofill/core/browser/field_types.h" | 10 #include "components/autofill/core/browser/field_types.h" |
| (...skipping 12 matching lines...) Expand all Loading... |
| 23 | 23 |
| 24 // Returns true if |text| looks like a valid credit card number. | 24 // Returns true if |text| looks like a valid credit card number. |
| 25 // Uses the Luhn formula to validate the number. | 25 // Uses the Luhn formula to validate the number. |
| 26 bool IsValidCreditCardNumber(const base::string16& text); | 26 bool IsValidCreditCardNumber(const base::string16& text); |
| 27 | 27 |
| 28 // Returns true if |code| looks like a valid credit card security code | 28 // Returns true if |code| looks like a valid credit card security code |
| 29 // for the given credit card type. | 29 // for the given credit card type. |
| 30 bool IsValidCreditCardSecurityCode(const base::string16& code, | 30 bool IsValidCreditCardSecurityCode(const base::string16& code, |
| 31 const base::StringPiece card_type); | 31 const base::StringPiece card_type); |
| 32 | 32 |
| 33 // Returns true if |text| is a supported card type and a valid credit card |
| 34 // number. |error_message| can't be null and will be filled with the appropriate |
| 35 // error message. |
| 36 bool IsValidCreditCardNumberForBasicCardNetworks( |
| 37 const base::string16& text, |
| 38 const std::set<std::string>& supported_basic_card_networks, |
| 39 base::string16* error_message); |
| 40 |
| 33 // Returns true if |text| looks like a valid e-mail address. | 41 // Returns true if |text| looks like a valid e-mail address. |
| 34 bool IsValidEmailAddress(const base::string16& text); | 42 bool IsValidEmailAddress(const base::string16& text); |
| 35 | 43 |
| 36 // Returns true if |text| is a valid US state name or abbreviation. It is | 44 // Returns true if |text| is a valid US state name or abbreviation. It is case |
| 37 // case insensitive. Valid for US states only. | 45 // insensitive. Valid for US states only. |
| 38 bool IsValidState(const base::string16& text); | 46 bool IsValidState(const base::string16& text); |
| 39 | 47 |
| 40 // Returns true if |text| looks like a valid zip code. | 48 // Returns true if |text| looks like a valid zip code. |
| 41 // Valid for US zip codes only. | 49 // Valid for US zip codes only. |
| 42 bool IsValidZip(const base::string16& text); | 50 bool IsValidZip(const base::string16& text); |
| 43 | 51 |
| 44 // Returns true if |text| looks like an SSN, with or without separators. | 52 // Returns true if |text| looks like an SSN, with or without separators. |
| 45 bool IsSSN(const base::string16& text); | 53 bool IsSSN(const base::string16& text); |
| 46 | 54 |
| 47 // Returns whether |value| is valid for the given |type|. If not null, | 55 // Returns whether |value| is valid for the given |type|. If not null, |
| 48 // |error_message| is populated when the function returns false. | 56 // |error_message| is populated when the function returns false. |
| 49 bool IsValidForType(const base::string16& value, | 57 bool IsValidForType(const base::string16& value, |
| 50 ServerFieldType type, | 58 ServerFieldType type, |
| 51 base::string16* error_message); | 59 base::string16* error_message); |
| 52 | 60 |
| 53 } // namespace autofill | 61 } // namespace autofill |
| 54 | 62 |
| 55 #endif // COMPONENTS_AUTOFILL_CORE_BROWSER_VALIDATION_H_ | 63 #endif // COMPONENTS_AUTOFILL_CORE_BROWSER_VALIDATION_H_ |
| OLD | NEW |