Skip to content

Latest commit

 

History

History

firestore-validate-address

Folders and files

NameName
Last commit message
Last commit date

parent directory

..
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 

Validate Address in Firestore

Author: Google Maps Platform (https://mapsplatform.google.com)

Description: Validates addresses in Firestore using the Address Validation API by Google Maps Platform.

Details: This extension validates and standardizes addresses in your Firestore documents in real-time.

On install, you will be asked to provide a target Firestore collection. When documents are created or updated within that collection, a Cloud Function is trigged that calls the Address Validation API to do the following:

  • Check whether the value at the address field is valid or not, and store the result in the addressValidity field.
  • If the address is valid, standardize the address field (field name is configurable).

For example, the following document:

{
    …,
    address: {
        addressLines: ["1600 Amphitheatre Parkway"],
        regionCode: "US",
        locality: "Mountain View",
    }
}

Will be transformed into the following document:

{
    …,
    address: {
        line1: "1600 Amphitheatre Parkway",
        city: "Mountain View",
        region: "CA",
        postalCode: "94043",
        country: "US"
    },
    addressValidity: true
}

Before installing

Before installing this extension, you must do the following in your Firebase project:

Billing

To install an extension, your project must be on the Blaze (pay as you go) plan.

You will be charged a small amount (typically around $0.01/month) for the Firebase resources required by this extension (even if it is not used).

This extension uses the following Firebase and Google Cloud services which may have associated charges if you exceed the service’s no-cost tier:

Configuration Parameters:

  • Addresses Collection: Firestore collection in which addresses are stored.

  • Google Address Validation API Key: API key for the Google Address Validation API. You can create an API key in the Google Cloud Console.

  • Cloud Functions location: Where do you want to deploy the functions created for this extension? You usually want a location close to your database. For help selecting a location, refer to the location selection guide.

Cloud Functions:

  • validateAddressTrigger: Processes document changes in the specified Cloud Firestore collection, syncing them to custom claims in Firebase Auth users.

  • retryOnUnknownError: Handles tasks from unknown address validation responses.

APIs Used:

  • addressvalidation.googleapis.com (Reason: Allows the extension to validate addresses using the Address Validation API.)

Access Required:

This extension will operate with the following project IAM roles:

  • datastore.user (Reason: Allows the extension to write sync information back to Firestore.)