Method: Worldwide::AddressValidator#errors

Defined in:
lib/worldwide/address_validator.rb

#errors(address) ⇒ Object

Return an array of diagnostics about the validity of this address. If no problems are found, then the result will be an empty array.



17
18
19
20
21
22
23
24
25
26
27
28
29
30
# File 'lib/worldwide/address_validator.rb', line 17

def errors(address)
  return [:address, :nil] if address.nil?

  result = []
  normalized_address = address.normalize(autocorrect_level: 0)

  result << country_errors(normalized_address)
  result << province_errors(normalized_address)
  result << zip_errors(normalized_address)
  result << phone_errors(normalized_address)
  result << city_errors(normalized_address)

  result.reject(&:empty?)
end