Skip to content

Commit

Permalink
Merge pull request #9 from conveyal/latitude-validation-fix
Browse files Browse the repository at this point in the history
fix(validation): correct error message for invalid latitude
  • Loading branch information
evansiroky authored Feb 25, 2017
2 parents 075e127 + 8d31b0a commit d1f467f
Show file tree
Hide file tree
Showing 2 changed files with 3 additions and 3 deletions.
4 changes: 2 additions & 2 deletions __snapshots__/index.test.js.snap
Original file line number Diff line number Diff line change
@@ -1,8 +1,8 @@
exports[`lonlat errors invalid coordinates should throw error when parsing: "-999,999" 1`] = `"Invalid longitude value: -999"`;

exports[`lonlat errors invalid coordinates should throw error when parsing: "0,999" 1`] = `"Invalid longitude value: 999"`;
exports[`lonlat errors invalid coordinates should throw error when parsing: "0,999" 1`] = `"Invalid latitude value: 999"`;

exports[`lonlat errors invalid coordinates should throw error when parsing: {"lng":1,"latitude":1234} 1`] = `"Invalid longitude value: 1234"`;
exports[`lonlat errors invalid coordinates should throw error when parsing: {"lng":1,"latitude":1234} 1`] = `"Invalid latitude value: 1234"`;

exports[`lonlat errors invalid coordinates should throw error when parsing: {} 1`] = `"Invalid longitude value: undefined"`;

Expand Down
2 changes: 1 addition & 1 deletion index.js
Original file line number Diff line number Diff line change
Expand Up @@ -62,7 +62,7 @@ function floatize (lonlat) {
throw new Error('Invalid longitude value: ' + (lonlat.lon || lonlat.lng || lonlat.longitude))
}
if ((!lat || lat > 90 || lat < -90) && lat !== 0) {
throw new Error('Invalid longitude value: ' + (lonlat.lat || lonlat.latitude))
throw new Error('Invalid latitude value: ' + (lonlat.lat || lonlat.latitude))
}
return {lon: lon, lat: lat}
}
Expand Down

0 comments on commit d1f467f

Please sign in to comment.