| 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, |
| (...skipping 99 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 110 const Ruleset* ruleset = ruleset_it->second; | 110 const Ruleset* ruleset = ruleset_it->second; |
| 111 assert(ruleset != NULL); | 111 assert(ruleset != NULL); |
| 112 const Rule& country_rule = | 112 const Rule& country_rule = |
| 113 ruleset->GetLanguageCodeRule(address.language_code); | 113 ruleset->GetLanguageCodeRule(address.language_code); |
| 114 | 114 |
| 115 // Validate required fields. | 115 // Validate required fields. |
| 116 for (std::vector<AddressField>::const_iterator | 116 for (std::vector<AddressField>::const_iterator |
| 117 field_it = country_rule.GetRequired().begin(); | 117 field_it = country_rule.GetRequired().begin(); |
| 118 field_it != country_rule.GetRequired().end(); | 118 field_it != country_rule.GetRequired().end(); |
| 119 ++field_it) { | 119 ++field_it) { |
| 120 if (address.GetField(*field_it).empty() && | 120 if (address.GetFieldValue(*field_it).empty() && |
| 121 FilterAllows( | 121 FilterAllows( |
| 122 filter, *field_it, AddressProblem::MISSING_REQUIRED_FIELD)) { | 122 filter, *field_it, AddressProblem::MISSING_REQUIRED_FIELD)) { |
| 123 problems->push_back(AddressProblem( | 123 problems->push_back(AddressProblem( |
| 124 *field_it, | 124 *field_it, |
| 125 AddressProblem::MISSING_REQUIRED_FIELD, | 125 AddressProblem::MISSING_REQUIRED_FIELD, |
| 126 localization.GetString( | 126 localization.GetString( |
| 127 IDS_LIBADDRESSINPUT_I18N_MISSING_REQUIRED_FIELD))); | 127 IDS_LIBADDRESSINPUT_I18N_MISSING_REQUIRED_FIELD))); |
| 128 } | 128 } |
| 129 } | 129 } |
| 130 | 130 |
| (...skipping 12 matching lines...) Expand all Loading... |
| 143 localization.GetString( | 143 localization.GetString( |
| 144 country_rule.GetInvalidPostalCodeMessageId()))); | 144 country_rule.GetInvalidPostalCodeMessageId()))); |
| 145 } | 145 } |
| 146 | 146 |
| 147 while (ruleset != NULL) { | 147 while (ruleset != NULL) { |
| 148 const Rule& rule = ruleset->GetLanguageCodeRule(address.language_code); | 148 const Rule& rule = ruleset->GetLanguageCodeRule(address.language_code); |
| 149 | 149 |
| 150 // Validate the field values, e.g. state names in US. | 150 // Validate the field values, e.g. state names in US. |
| 151 AddressField sub_field_type = | 151 AddressField sub_field_type = |
| 152 static_cast<AddressField>(ruleset->field() + 1); | 152 static_cast<AddressField>(ruleset->field() + 1); |
| 153 const std::string& sub_field = address.GetField(sub_field_type); | 153 const std::string& sub_field = address.GetFieldValue(sub_field_type); |
| 154 const std::vector<std::string>& sub_keys = rule.GetSubKeys(); | 154 const std::vector<std::string>& sub_keys = rule.GetSubKeys(); |
| 155 if (!sub_field.empty() && | 155 if (!sub_field.empty() && |
| 156 !sub_keys.empty() && | 156 !sub_keys.empty() && |
| 157 FilterAllows(filter, sub_field_type, AddressProblem::UNKNOWN_VALUE) && | 157 FilterAllows(filter, sub_field_type, AddressProblem::UNKNOWN_VALUE) && |
| 158 std::find(sub_keys.begin(), sub_keys.end(), sub_field) == | 158 std::find(sub_keys.begin(), sub_keys.end(), sub_field) == |
| 159 sub_keys.end()) { | 159 sub_keys.end()) { |
| 160 problems->push_back(AddressProblem( | 160 problems->push_back(AddressProblem( |
| 161 sub_field_type, | 161 sub_field_type, |
| 162 AddressProblem::UNKNOWN_VALUE, | 162 AddressProblem::UNKNOWN_VALUE, |
| 163 localization.GetString( | 163 localization.GetString( |
| (...skipping 68 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 232 scoped_ptr<AddressValidator> AddressValidator::Build( | 232 scoped_ptr<AddressValidator> AddressValidator::Build( |
| 233 scoped_ptr<Downloader> downloader, | 233 scoped_ptr<Downloader> downloader, |
| 234 scoped_ptr<Storage> storage, | 234 scoped_ptr<Storage> storage, |
| 235 LoadRulesDelegate* load_rules_delegate) { | 235 LoadRulesDelegate* load_rules_delegate) { |
| 236 return scoped_ptr<AddressValidator>(new AddressValidatorImpl( | 236 return scoped_ptr<AddressValidator>(new AddressValidatorImpl( |
| 237 downloader.Pass(), storage.Pass(), load_rules_delegate)); | 237 downloader.Pass(), storage.Pass(), load_rules_delegate)); |
| 238 } | 238 } |
| 239 | 239 |
| 240 } // namespace addressinput | 240 } // namespace addressinput |
| 241 } // namespace i18n | 241 } // namespace i18n |
| OLD | NEW |