Skip to content

Instantly share code, notes, and snippets.

@madeleine-chercover-hs
Last active December 15, 2017 21:20
Show Gist options
  • Save madeleine-chercover-hs/d1f0e846443cf76086c776161ed85966 to your computer and use it in GitHub Desktop.
Save madeleine-chercover-hs/d1f0e846443cf76086c776161ed85966 to your computer and use it in GitHub Desktop.
class InvalidLatLongException(latitude: Double, longitude: Double) extends Exception
def validateLatLong(latitude: Double, longitude: Double): Either[InvalidLatLongException, (Double, Double)] =
if (latitude < -90 || latitude > 90 || longitude < -180 || longitude > 180)
Left(InvalidLatLongException(latitude, longitude))
else
Right((latitude, longitude))
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment