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 52 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
63 // missing, the message will be a generic "more information required". | 63 // missing, the message will be a generic "more information required". |
64 base::string16 GetCompletionMessageForCard(CreditCardCompletionStatus status); | 64 base::string16 GetCompletionMessageForCard(CreditCardCompletionStatus status); |
65 | 65 |
66 // Returns true if |text| looks like a valid e-mail address. | 66 // Returns true if |text| looks like a valid e-mail address. |
67 bool IsValidEmailAddress(const base::string16& text); | 67 bool IsValidEmailAddress(const base::string16& text); |
68 | 68 |
69 // Returns true if |text| is a valid US state name or abbreviation. It is case | 69 // Returns true if |text| is a valid US state name or abbreviation. It is case |
70 // insensitive. Valid for US states only. | 70 // insensitive. Valid for US states only. |
71 bool IsValidState(const base::string16& text); | 71 bool IsValidState(const base::string16& text); |
72 | 72 |
73 // Returns whether the number contained in |text| is valid for the specified | 73 // Returns whether the number contained in |text| is valid, either in |
| 74 // international format, or in the national format associated with |
74 // |country_code|. Callers should cache the result as the parsing is expensive. | 75 // |country_code|. Callers should cache the result as the parsing is expensive. |
75 bool IsValidPhoneNumber(const base::string16& text, | 76 bool IsValidPhoneNumber(const base::string16& text, |
76 const std::string& country_code); | 77 const std::string& country_code); |
77 | 78 |
78 // Returns true if |text| looks like a valid zip code. | 79 // Returns true if |text| looks like a valid zip code. |
79 // Valid for US zip codes only. | 80 // Valid for US zip codes only. |
80 bool IsValidZip(const base::string16& text); | 81 bool IsValidZip(const base::string16& text); |
81 | 82 |
82 // Returns true if |text| looks like an SSN, with or without separators. | 83 // Returns true if |text| looks like an SSN, with or without separators. |
83 bool IsSSN(const base::string16& text); | 84 bool IsSSN(const base::string16& text); |
84 | 85 |
85 // Returns whether |value| is valid for the given |type|. If not null, | 86 // Returns whether |value| is valid for the given |type|. If not null, |
86 // |error_message| is populated when the function returns false. | 87 // |error_message| is populated when the function returns false. |
87 bool IsValidForType(const base::string16& value, | 88 bool IsValidForType(const base::string16& value, |
88 ServerFieldType type, | 89 ServerFieldType type, |
89 base::string16* error_message); | 90 base::string16* error_message); |
90 | 91 |
91 // Returns the expected CVC length based on the |card_type|. | 92 // Returns the expected CVC length based on the |card_type|. |
92 size_t GetCvcLengthForCardType(const base::StringPiece card_type); | 93 size_t GetCvcLengthForCardType(const base::StringPiece card_type); |
93 | 94 |
94 // Returns true if |value| appears to be a UPI Virtual Payment Address. | 95 // Returns true if |value| appears to be a UPI Virtual Payment Address. |
95 // https://upipayments.co.in/virtual-payment-address-vpa/ | 96 // https://upipayments.co.in/virtual-payment-address-vpa/ |
96 bool IsUPIVirtualPaymentAddress(const base::string16& value); | 97 bool IsUPIVirtualPaymentAddress(const base::string16& value); |
97 | 98 |
98 } // namespace autofill | 99 } // namespace autofill |
99 | 100 |
100 #endif // COMPONENTS_AUTOFILL_CORE_BROWSER_VALIDATION_H_ | 101 #endif // COMPONENTS_AUTOFILL_CORE_BROWSER_VALIDATION_H_ |
OLD | NEW |