Shippex.validate_address
You're seeing just the function
validate_address, go back to Shippex module for more information.
Specs
validate_address(Shippex.Address.t(), Keyword.t()) :: {atom(), response() | [Shippex.Address.t()]}
Performs address validation. If the address is completely invalid,
{:error, result} is returned. For addresses that may have typos,
{:ok, candidates} is returned. You can iterate through the list of
candidates to present to the end user. Addresses that pass validation
perfectly will still be in a list where length(candidates) == 1.
Note that the candidates returned will automatically pass through
Shippex.Address.address() for casting. Also, if :usps is used as the
validation provider, the number of candidates will always be 1.
address = Shippex.Address.address(%{
name: "Earl G",
phone: "123-123-1234",
address: "9999 Hobby Lane",
address_line_2: nil,
city: "Austin",
state: "TX",
postal_code: "78703"
})
case Shippex.validate_address(address) do
{:error, %{code: code, message: message}} ->
# Present the error.
{:ok, candidates} when length(candidates) == 1 ->
# Use the address
{:ok, candidates} when length(candidates) > 1 ->
# Present candidates to user for selection
end