| 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. |
| 35 bool IsValidCreditCardNumberForBasicCardNetworks( |
| 36 const base::string16& text, |
| 37 const std::set<std::string>& supported_basic_card_networks, |
| 38 base::string16* error_message); |
| 39 |
| 33 // Returns true if |text| looks like a valid e-mail address. | 40 // Returns true if |text| looks like a valid e-mail address. |
| 34 bool IsValidEmailAddress(const base::string16& text); | 41 bool IsValidEmailAddress(const base::string16& text); |
| 35 | 42 |
| 36 // Returns true if |text| is a valid US state name or abbreviation. It is | 43 // Returns true if |text| is a valid US state name or abbreviation. It is case |
| 37 // case insensitive. Valid for US states only. | 44 // insensitive. Valid for US states only. |
| 38 bool IsValidState(const base::string16& text); | 45 bool IsValidState(const base::string16& text); |
| 39 | 46 |
| 40 // Returns true if |text| looks like a valid zip code. | 47 // Returns true if |text| looks like a valid zip code. |
| 41 // Valid for US zip codes only. | 48 // Valid for US zip codes only. |
| 42 bool IsValidZip(const base::string16& text); | 49 bool IsValidZip(const base::string16& text); |
| 43 | 50 |
| 44 // Returns true if |text| looks like an SSN, with or without separators. | 51 // Returns true if |text| looks like an SSN, with or without separators. |
| 45 bool IsSSN(const base::string16& text); | 52 bool IsSSN(const base::string16& text); |
| 46 | 53 |
| 47 // Returns whether |value| is valid for the given |type|. If not null, | 54 // Returns whether |value| is valid for the given |type|. If not null, |
| 48 // |error_message| is populated when the function returns false. | 55 // |error_message| is populated when the function returns false. |
| 49 bool IsValidForType(const base::string16& value, | 56 bool IsValidForType(const base::string16& value, |
| 50 ServerFieldType type, | 57 ServerFieldType type, |
| 51 base::string16* error_message); | 58 base::string16* error_message); |
| 52 | 59 |
| 53 } // namespace autofill | 60 } // namespace autofill |
| 54 | 61 |
| 55 #endif // COMPONENTS_AUTOFILL_CORE_BROWSER_VALIDATION_H_ | 62 #endif // COMPONENTS_AUTOFILL_CORE_BROWSER_VALIDATION_H_ |
| OLD | NEW |