1// Copyright (C) 2014 Google Inc. 2// 3// Licensed under the Apache License, Version 2.0 (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 6// 7// http://www.apache.org/licenses/LICENSE-2.0 8// 9// Unless required by applicable law or agreed to in writing, software 10// distributed under the License is distributed on an "AS IS" BASIS, 11// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 12// See the License for the specific language governing permissions and 13// limitations under the License. 14 15#ifndef I18N_ADDRESSINPUT_ADDRESS_PROBLEM_H_ 16#define I18N_ADDRESSINPUT_ADDRESS_PROBLEM_H_ 17 18#include <iosfwd> 19 20namespace i18n { 21namespace addressinput { 22 23// Address problem types, in no particular order. 24enum AddressProblem { 25 // The field is not null and not whitespace, and the field should not be used 26 // by addresses in this country. For example, in the U.S. the SORTING_CODE 27 // field is unused, so its presence is an error. 28 UNEXPECTED_FIELD, 29 30 // The field is null or whitespace, and the field is required. For example, 31 // in the U.S. ADMIN_AREA is a required field. 32 MISSING_REQUIRED_FIELD, 33 34 // A list of values for the field is defined and the value does not occur in 35 // the list. Applies to hierarchical elements like REGION, ADMIN_AREA, 36 // LOCALITY, and DEPENDENT_LOCALITY. For example, in the US, the values for 37 // ADMIN_AREA include "CA" but not "XX". 38 UNKNOWN_VALUE, 39 40 // A format for the field is defined and the value does not match. This is 41 // used to match POSTAL_CODE against the the format pattern generally. Formats 42 // indicate how many digits/letters should be present, and what punctuation is 43 // allowed. For example, in the U.S. postal codes are five digits with an 44 // optional hyphen followed by four digits. 45 INVALID_FORMAT, 46 47 // A specific pattern for the field is defined based on a specific sub-region 48 // (an ADMIN_AREA for example) and the value does not match. This is used to 49 // match POSTAL_CODE against a regular expression. For example, in the U.S. 50 // postal codes in the state of California start with '9'. 51 MISMATCHING_VALUE, 52 53 // The value contains a P.O. box and the widget options have acceptPostal set 54 // to false. For example, a street address line that contained "P.O. Box 3456" 55 // would fire this error. 56 USES_P_O_BOX 57}; 58 59} // namespace addressinput 60} // namespace i18n 61 62// Produces human-readable output in logging, for example in unit tests. Prints 63// what you would expect for valid values, e.g. "UNEXPECTED_FIELD" for 64// UNEXPECTED_FIELD. For invalid values, prints "[INVALID ENUM VALUE x]". 65std::ostream& operator<<(std::ostream& o, 66 i18n::addressinput::AddressProblem problem); 67 68#endif // I18N_ADDRESSINPUT_ADDRESS_PROBLEM_H_ 69