Autocomplete Address Validation

Think I finally got it working.

JSON.Parse() was causing unknown console errors.

Did some research and tested the below and seems to be working thus far.


$w.onReady(function () {
$w("#addressInput1").onCustomValidation((value, reject) => {
      
let fullAddress = value;

function GetPropertyValue(obj1, dataToRetrieve) {
  return dataToRetrieve
    .split('.') // split string based on `.`
    .reduce(function(o, k) {
      return o && o[k]; // get inner property if `o` is defined else get `o` and return
    }, obj1) // set initial value as object
}

let location = GetPropertyValue(fullAddress, "location");


if (location === undefined) {
             reject("Please select an address option only.");
        }

});
});

Open to hearing a better way to write this out