OLD | NEW |
1 // Copyright (C) 2013 Google Inc. | 1 // Copyright (C) 2013 Google Inc. |
2 // | 2 // |
3 // Licensed under the Apache License, Version 2.0 (the "License"); | 3 // Licensed under the Apache License, Version 2.0 (the "License"); |
4 // you may not use this file except in compliance with the License. | 4 // you may not use this file except in compliance with the License. |
5 // You may obtain a copy of the License at | 5 // You may obtain a copy of the License at |
6 // | 6 // |
7 // http://www.apache.org/licenses/LICENSE-2.0 | 7 // http://www.apache.org/licenses/LICENSE-2.0 |
8 // | 8 // |
9 // Unless required by applicable law or agreed to in writing, software | 9 // Unless required by applicable law or agreed to in writing, software |
10 // distributed under the License is distributed on an "AS IS" BASIS, | 10 // distributed under the License is distributed on an "AS IS" BASIS, |
11 // WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. | 11 // WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. |
12 // See the License for the specific language governing permissions and | 12 // See the License for the specific language governing permissions and |
13 // limitations under the License. | 13 // limitations under the License. |
14 | 14 |
15 #ifndef I18N_ADDRESSINPUT_ADDRESS_PROBLEM_H_ | 15 #ifndef I18N_ADDRESSINPUT_ADDRESS_PROBLEM_H_ |
16 #define I18N_ADDRESSINPUT_ADDRESS_PROBLEM_H_ | 16 #define I18N_ADDRESSINPUT_ADDRESS_PROBLEM_H_ |
17 | 17 |
18 #include <libaddressinput/address_field.h> | 18 #include <libaddressinput/address_field.h> |
19 | 19 |
20 #include <iosfwd> | 20 #include <iosfwd> |
21 #include <string> | |
22 | 21 |
23 namespace i18n { | 22 namespace i18n { |
24 namespace addressinput { | 23 namespace addressinput { |
25 | 24 |
26 // A problem for address validation. | 25 // A problem for address validation. |
27 struct AddressProblem { | 26 struct AddressProblem { |
28 // Types of problems encountered in address validation. | 27 // Types of problems encountered in address validation. |
29 enum Type { | 28 enum Type { |
30 // The field is empty or whitespace, but it is required for addresses in | 29 // The field is empty or whitespace, but it is required for addresses in |
31 // this country. | 30 // this country. |
(...skipping 20 matching lines...) Expand all Loading... |
52 | 51 |
53 // A specific pattern for the field is defined based on a specific | 52 // A specific pattern for the field is defined based on a specific |
54 // sub-region (an administrative area for example), but the value does not | 53 // sub-region (an administrative area for example), but the value does not |
55 // match. This is used to match postal code against a regular expression. | 54 // match. This is used to match postal code against a regular expression. |
56 // | 55 // |
57 // For example, in the US, postal codes in the state of California start | 56 // For example, in the US, postal codes in the state of California start |
58 // with a '9'. | 57 // with a '9'. |
59 MISMATCHING_VALUE | 58 MISMATCHING_VALUE |
60 }; | 59 }; |
61 | 60 |
62 AddressProblem(AddressField field, Type type, const std::string& description); | 61 AddressProblem(AddressField field, Type type, int description_id); |
63 ~AddressProblem(); | 62 ~AddressProblem(); |
64 | 63 |
65 // The address field that has the problem. | 64 // The address field that has the problem. |
66 AddressField field; | 65 AddressField field; |
67 | 66 |
68 // The type of problem. | 67 // The type of problem. |
69 Type type; | 68 Type type; |
70 | 69 |
71 // The human readable description of the problem. | 70 // The ID for the string that is the human readable description of the |
72 std::string description; | 71 // problem. |
| 72 int description_id; |
73 }; | 73 }; |
74 | 74 |
75 // Produces human-readable output in logging, for example in unit tests. | 75 // Produces human-readable output in logging, for example in unit tests. |
76 // Produces what you would expect for valid values, e.g. | 76 // Produces what you would expect for valid values, e.g. |
77 // "MISSING_REQUIRED_FIELD" for MISSING_REQUIRED_FIELD. For invalid values, | 77 // "MISSING_REQUIRED_FIELD" for MISSING_REQUIRED_FIELD. For invalid values, |
78 // produces "[INVALID]". | 78 // produces "[INVALID]". |
79 std::ostream& operator<<(std::ostream& o, AddressProblem::Type problem_type); | 79 std::ostream& operator<<(std::ostream& o, AddressProblem::Type problem_type); |
80 | 80 |
81 // Produces human-readable output in logging, for example in unit tests. | 81 // Produces human-readable output in logging, for example in unit tests. |
82 // Example: [ADMIN_AREA, UNKNOWN_VALUE, "Invalid state"]. | 82 // Example: [ADMIN_AREA, UNKNOWN_VALUE, "Invalid state"]. |
83 std::ostream& operator<<(std::ostream& o, const AddressProblem& problem); | 83 std::ostream& operator<<(std::ostream& o, const AddressProblem& problem); |
84 | 84 |
85 } // namespace addressinput | 85 } // namespace addressinput |
86 } // namespace i18n | 86 } // namespace i18n |
87 | 87 |
88 #endif // I18N_ADDRESSINPUT_ADDRESS_PROBLEM_H_ | 88 #endif // I18N_ADDRESSINPUT_ADDRESS_PROBLEM_H_ |
OLD | NEW |