0

I need to implement a GeoPointField with Doctrine2.

It seems that Zend and Doctrine don't support it natively...

Is there a best practice for validating such an input? In the database I'd use a simple string field, right?

j0k
  • 22,600
  • 28
  • 79
  • 90
Ron
  • 22,128
  • 31
  • 108
  • 206

1 Answers1

1
/^(\-?\d+(?:\.\d+)?),?\s*(\-?\d+(?:\.\d+)?)$/

This regexp validates and captures GEO input:

  • Latitude, Longitude
  • Latitude Longitude
  • Coords copied directly from GoogleMaps
Paul T. Rawkeen
  • 3,994
  • 3
  • 35
  • 51
  • I chose a standard regex validation, this works just fine except for the error message: http://stackoverflow.com/q/14068446/1331671 – Ron Dec 28 '12 at 10:57
  • @Ron, so you was simply asking about form field and validation of user input? – Paul T. Rawkeen Dec 28 '12 at 11:04
  • no, at first i wanted to have a built-in solution. but it seems that going with regex is a lighter and easier way. thanks for your post anyway :) – Ron Dec 28 '12 at 11:06
  • @Ron, sorry for my inattentiveness. I revised my answer. I wrote this `regexp` for validating GEO coordinates input in one of my projects. Works perfectly. – Paul T. Rawkeen Dec 28 '12 at 11:09