| 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 31 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 42 const std::set<std::string>& supported_basic_card_networks, | 42 const std::set<std::string>& supported_basic_card_networks, |
| 43 base::string16* error_message); | 43 base::string16* error_message); |
| 44 | 44 |
| 45 // Returns true if |text| looks like a valid e-mail address. | 45 // Returns true if |text| looks like a valid e-mail address. |
| 46 bool IsValidEmailAddress(const base::string16& text); | 46 bool IsValidEmailAddress(const base::string16& text); |
| 47 | 47 |
| 48 // Returns true if |text| is a valid US state name or abbreviation. It is case | 48 // Returns true if |text| is a valid US state name or abbreviation. It is case |
| 49 // insensitive. Valid for US states only. | 49 // insensitive. Valid for US states only. |
| 50 bool IsValidState(const base::string16& text); | 50 bool IsValidState(const base::string16& text); |
| 51 | 51 |
| 52 // Returns whether the number contained in |text| is valid for the specified | 52 // Returns whether the number contained in |text| is valid, either in |
| 53 // international format, or in the national format associated with |
| 53 // |country_code|. Callers should cache the result as the parsing is expensive. | 54 // |country_code|. Callers should cache the result as the parsing is expensive. |
| 54 bool IsValidPhoneNumber(const base::string16& text, | 55 bool IsValidPhoneNumber(const base::string16& text, |
| 55 const std::string& country_code); | 56 const std::string& country_code); |
| 56 | 57 |
| 57 // Returns true if |text| looks like a valid zip code. | 58 // Returns true if |text| looks like a valid zip code. |
| 58 // Valid for US zip codes only. | 59 // Valid for US zip codes only. |
| 59 bool IsValidZip(const base::string16& text); | 60 bool IsValidZip(const base::string16& text); |
| 60 | 61 |
| 61 // Returns true if |text| looks like an SSN, with or without separators. | 62 // Returns true if |text| looks like an SSN, with or without separators. |
| 62 bool IsSSN(const base::string16& text); | 63 bool IsSSN(const base::string16& text); |
| 63 | 64 |
| 64 // Returns whether |value| is valid for the given |type|. If not null, | 65 // Returns whether |value| is valid for the given |type|. If not null, |
| 65 // |error_message| is populated when the function returns false. | 66 // |error_message| is populated when the function returns false. |
| 66 bool IsValidForType(const base::string16& value, | 67 bool IsValidForType(const base::string16& value, |
| 67 ServerFieldType type, | 68 ServerFieldType type, |
| 68 base::string16* error_message); | 69 base::string16* error_message); |
| 69 | 70 |
| 70 // Returns the expected CVC length based on the |card_type|. | 71 // Returns the expected CVC length based on the |card_type|. |
| 71 size_t GetCvcLengthForCardType(const base::StringPiece card_type); | 72 size_t GetCvcLengthForCardType(const base::StringPiece card_type); |
| 72 | 73 |
| 73 // Returns true if |value| appears to be a UPI Virtual Payment Address. | 74 // Returns true if |value| appears to be a UPI Virtual Payment Address. |
| 74 // https://upipayments.co.in/virtual-payment-address-vpa/ | 75 // https://upipayments.co.in/virtual-payment-address-vpa/ |
| 75 bool IsUPIVirtualPaymentAddress(const base::string16& value); | 76 bool IsUPIVirtualPaymentAddress(const base::string16& value); |
| 76 | 77 |
| 77 } // namespace autofill | 78 } // namespace autofill |
| 78 | 79 |
| 79 #endif // COMPONENTS_AUTOFILL_CORE_BROWSER_VALIDATION_H_ | 80 #endif // COMPONENTS_AUTOFILL_CORE_BROWSER_VALIDATION_H_ |
| OLD | NEW |