Hi all, I’m working on a functionality where I request additional data from an API (using Remote::get) based on the content of couple of fields during the page.update:after hook. I will save the additional data from the API to the corresponding page with $newPage→update([ ..fields.. ]).
Since the data comes from an external source (the API) it is probably good practice to validate (preferred) or sanitise the data before saving it to the page. What would be the best approach to make sure the data is secure before saving it? Thank you!
I managed to find a solution, in my case I just needed to check some latitude and longitude values returned by the Mapbox API. I created a helper function (in a class, hence the private) which will check if the values exist, are of the right type (number) and within the expected range. If this is not the case it will throw an exception. If everything is good it will return an array with the latitude and longitude values.