Skip to content
Snippets Groups Projects

correct typing and fix a bug

Merged Mohammad Torkashvand requested to merge refactor/improve-lat-lon-validation into develop
All threads resolved!
Files
13
+ 6
8
@@ -8,12 +8,11 @@ class LatitudeCoordinate(ConstrainedStr):
"""A latitude coordinate, modeled as a constrained string.
The coordinate must match the format conforming to the latitude
range of -90 to 90 degrees. It can be a floating-point number or an integer.
Valid examples: "40.7128", "-74.0060", "90", "-90", "0".
range of `-`90 to +90 degrees. It can be a floating-point number or an integer.
Valid examples: 40.7128, -74.0060, 90, -90, 0
"""
regex = re.compile(r"^[-+]?([1-8]?\d(\.\d+)?|90(\.0+)?)$")
regex = re.compile(r"^-?([1-8]?\d(\.\d+)?|90(\.0+)?)$")
@classmethod
def validate(cls, value: Union[str]) -> Union[str]:
@@ -27,12 +26,11 @@ class LongitudeCoordinate(ConstrainedStr):
"""A longitude coordinate, modeled as a constrained string.
The coordinate must match the format conforming to the longitude
range of -180 to 180 degrees. It can be a floating-point number or an integer.
Valid examples: "40.7128", "-74.0060", "180", "-180", "0".
range of `-`180 to 180 degrees. It can be a floating point number or an integer.
Valid examples: 40.7128, -74.0060, 180, -180, 0
"""
regex = re.compile(r"^[-+]?(180(\.0+)?|((1[0-7]\d)|([1-9]?\d))(\.\d+)?)$")
regex = re.compile(r"^-?(180(\.0+)?|((1[0-7]\d)|([1-9]?\d))(\.\d+)?)$")
@classmethod
def validate(cls, value: Union[str]) -> Union[str]:
Loading