nycmeshnet / meshdb

A convenient, stable, and sane database for tracking Members and Nodes for use with robots and humans
https://db.nycmesh.net
MIT License
8 stars 13 forks source link

Validate form fields such as email, phone number, and address #59

Closed WillNilges closed 7 months ago

WillNilges commented 1 year ago

I think I got email covered using EmailField, but we need a way to validate peoples' phone number formats, and their addresses.

https://github.com/andybaumgar/meshdb/blob/90e51008b810cb1c305e8950396c85f0a7354263/src/meshapi/models.py#L31

https://github.com/andybaumgar/meshdb/blob/90e51008b810cb1c305e8950396c85f0a7354263/src/meshapi/models.py#L14-L17

WillNilges commented 1 year ago

@andybaumgar

@willard Yeah not really relevant to this PR but we need to "geocode" the address at some point in order to get the lat long. That could be in a separate view.

quoncc commented 1 year ago

Just found this, which could be interesting. If I'm understanding correctly, this will use the Google Maps API to determine a correct address given an input.

Will try and play with it.

quoncc commented 1 year ago

Oh boy, address validation is a bit of a rabbit hole.

We could use Google's GeoCoding API, but it's only free for 40k requests per month. Unlikely we'd go over that, but someone could just hammer us with requests and rack up charges.

I haven't found much else that's super helpful.

andybaumgar commented 1 year ago

This has been an issue in the past, we periodically have to top up the prepaid card linked to a Google Cloud Maps API account. But so long as we are careful about storing the georeference in the db we should be able to use a single API call for each install request which is only a few cents.

That's a good point about someone doing fake requests. We should probably have some sort of alert if the API call fails. Or maybe just a unit test that runs each night.

WillNilges commented 1 year ago

If it ain't broke don't fix it, but would OpenStreetMap be a better choice for this? https://wiki.openstreetmap.org/wiki/API We want the Overpass API (read-only) https://wiki.openstreetmap.org/wiki/Overpass_API

andybaumgar commented 1 year ago

This would be cool assuming it is accurate. It would remove the need for the maps API.

In the past I had issues with other free services because they introduced an offset from the Google Maps data.

Andrew-Dickinson commented 7 months ago

Complete via #76