addressinput_util.h 2.3 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657
  1. // Copyright 2014 The Chromium Authors. All rights reserved.
  2. // Use of this source code is governed by a BSD-style license that can be
  3. // found in the LICENSE file.
  4. #ifndef THIRD_PARTY_LIBADDRESSINPUT_CHROMIUM_ADDRESSINPUT_UTIL_H_
  5. #define THIRD_PARTY_LIBADDRESSINPUT_CHROMIUM_ADDRESSINPUT_UTIL_H_
  6. #include <map>
  7. #include "third_party/libaddressinput/src/cpp/include/libaddressinput/address_field.h"
  8. #include "third_party/libaddressinput/src/cpp/include/libaddressinput/address_problem.h"
  9. namespace i18n {
  10. namespace addressinput {
  11. struct AddressData;
  12. } // namespace addressinput
  13. } // namespace i18n
  14. namespace autofill {
  15. namespace addressinput {
  16. // Returns true if |address_to_check| has all of its required fields.
  17. bool HasAllRequiredFields(
  18. const ::i18n::addressinput::AddressData& address_to_check);
  19. // Validates required fields in |address_to_check| without loading rules from
  20. // the server. The |problems| parameter cannot be NULL. Does not take ownership
  21. // of its parameters.
  22. //
  23. // See documentation of ::i18n::addressinput::AddressValidator::Validate() for
  24. // description of |inclusion_filter| and |problems|.
  25. void ValidateRequiredFields(
  26. const ::i18n::addressinput::AddressData& address_to_check,
  27. const std::multimap<::i18n::addressinput::AddressField,
  28. ::i18n::addressinput::AddressProblem>* inclusion_filter,
  29. std::multimap<::i18n::addressinput::AddressField,
  30. ::i18n::addressinput::AddressProblem>* problems);
  31. // Validates required fields in |address_to_check| without loading rules from
  32. // the server. The |problems| parameter cannot be NULL. Does not take ownership
  33. // of its parameters.
  34. //
  35. // Usage of |exclusion_filter| differs from the description in
  36. // ::i18n::addressinput::AddressValidator::Validate() in that it excludes
  37. // contained elements instead of including them. It behaves the same for NULL
  38. // or empty filters.
  39. void ValidateRequiredFieldsExceptFilteredOut(
  40. const ::i18n::addressinput::AddressData& address_to_check,
  41. const std::multimap<::i18n::addressinput::AddressField,
  42. ::i18n::addressinput::AddressProblem>* exclusion_filter,
  43. std::multimap<::i18n::addressinput::AddressField,
  44. ::i18n::addressinput::AddressProblem>* problems);
  45. } // namespace addressinput
  46. } // namespace autofill
  47. #endif // THIRD_PARTY_LIBADDRESSINPUT_CHROMIUM_ADDRESSINPUT_UTIL_H_