cuenca-validations 2.1.5.dev3__py3-none-any.whl → 2.1.5.dev4__py3-none-any.whl
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- cuenca_validations/types/requests.py +21 -2
- cuenca_validations/version.py +1 -1
- {cuenca_validations-2.1.5.dev3.dist-info → cuenca_validations-2.1.5.dev4.dist-info}/METADATA +1 -1
- {cuenca_validations-2.1.5.dev3.dist-info → cuenca_validations-2.1.5.dev4.dist-info}/RECORD +8 -8
- {cuenca_validations-2.1.5.dev3.dist-info → cuenca_validations-2.1.5.dev4.dist-info}/WHEEL +1 -1
- tests/test_types.py +32 -0
- {cuenca_validations-2.1.5.dev3.dist-info → cuenca_validations-2.1.5.dev4.dist-info}/licenses/LICENSE +0 -0
- {cuenca_validations-2.1.5.dev3.dist-info → cuenca_validations-2.1.5.dev4.dist-info}/top_level.txt +0 -0
|
@@ -9,9 +9,11 @@ from pydantic import (
|
|
|
9
9
|
Field,
|
|
10
10
|
StrictStr,
|
|
11
11
|
StringConstraints,
|
|
12
|
+
TypeAdapter,
|
|
12
13
|
field_validator,
|
|
13
14
|
model_validator,
|
|
14
15
|
)
|
|
16
|
+
from pydantic_extra_types.coordinate import Latitude, Longitude
|
|
15
17
|
|
|
16
18
|
from ..types.enums import (
|
|
17
19
|
AuthorizerTransaction,
|
|
@@ -405,8 +407,25 @@ class TOSRequest(BaseModel):
|
|
|
405
407
|
class UserTOSAgreementRequest(BaseModel):
|
|
406
408
|
user_id: str
|
|
407
409
|
tos_id: str
|
|
408
|
-
location:
|
|
409
|
-
|
|
410
|
+
location: str
|
|
411
|
+
|
|
412
|
+
@field_validator('location')
|
|
413
|
+
@classmethod
|
|
414
|
+
def validate_location(cls, value: str) -> str:
|
|
415
|
+
values = value.split(',')
|
|
416
|
+
if len(values) != 3:
|
|
417
|
+
raise ValueError(
|
|
418
|
+
'Must provide exactly 3 values for location: lat,lon,alt'
|
|
419
|
+
)
|
|
420
|
+
try:
|
|
421
|
+
lat, lon, alt = map(float, values)
|
|
422
|
+
TypeAdapter(Latitude).validate_python(lat)
|
|
423
|
+
TypeAdapter(Longitude).validate_python(lon)
|
|
424
|
+
except ValueError:
|
|
425
|
+
raise ValueError(
|
|
426
|
+
'Invalid format. Use lat,lon,alt with float valid values.'
|
|
427
|
+
)
|
|
428
|
+
return value
|
|
410
429
|
|
|
411
430
|
|
|
412
431
|
class UserRequest(BaseModel):
|
cuenca_validations/version.py
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
__version__ = '2.1.5.
|
|
1
|
+
__version__ = '2.1.5.dev4'
|
|
@@ -4,7 +4,7 @@ cuenca_validations/errors.py,sha256=OtM8EgiKqYdz9Hn66AbBO96orL1or7efkyt0vh0Zxbs,
|
|
|
4
4
|
cuenca_validations/py.typed,sha256=47DEQpj8HBSa-_TImW-5JCeuQeRkm5NMpJWZG3hSuFU,0
|
|
5
5
|
cuenca_validations/typing.py,sha256=1QCu81IbVZZpyInjyeAuO-nF36gpT5Gi4o6V9PozuOU,204
|
|
6
6
|
cuenca_validations/validators.py,sha256=wzwLnJ4wHggZvqp3mearbFkzvDERGeTNvJkuofQnuMc,1484
|
|
7
|
-
cuenca_validations/version.py,sha256=
|
|
7
|
+
cuenca_validations/version.py,sha256=vkrrbxTqNBCiWkVGSHCSIpu2bzyE1yysxhcX187vJzk,27
|
|
8
8
|
cuenca_validations/types/__init__.py,sha256=8fiuz26oYQT2DriQ7sbD740yFJergVhB1OYoUGETB5A,4783
|
|
9
9
|
cuenca_validations/types/card.py,sha256=UGzz8NTFAverUmdUKAK1oGHnOnjSNTpIRUm93vKSSGY,1295
|
|
10
10
|
cuenca_validations/types/enums.py,sha256=47lvhRmmOwsoXBI6JiH0QCiLabqsBpYOZqHJxV3xVak,18887
|
|
@@ -14,15 +14,15 @@ cuenca_validations/types/helpers.py,sha256=6rHUhwoQ7jJZtGcW3LX-W5ZDl42PWE1RoBpGm
|
|
|
14
14
|
cuenca_validations/types/identities.py,sha256=-TWRDRpmIaCI4nE4hVy1FQtQtlxuErtmEtzJW1FBzec,4956
|
|
15
15
|
cuenca_validations/types/morals.py,sha256=m8kAedevmwfSPTA9GYe03l7pkgipynwYgKfejyVtnuI,1813
|
|
16
16
|
cuenca_validations/types/queries.py,sha256=KCRx0sPzWDtDDbZysmFGVgANgfqil17EITWaG7tGQ-A,4700
|
|
17
|
-
cuenca_validations/types/requests.py,sha256=
|
|
18
|
-
cuenca_validations-2.1.5.
|
|
17
|
+
cuenca_validations/types/requests.py,sha256=wSfTn4CzR2SLYauf98yXbHwVWGT95bt6bLJcbV0L0b8,22039
|
|
18
|
+
cuenca_validations-2.1.5.dev4.dist-info/licenses/LICENSE,sha256=wR76FmxBbfnQpwELkkE5iMF8sFIafEMgXLTE4N4WPTc,1063
|
|
19
19
|
tests/__init__.py,sha256=47DEQpj8HBSa-_TImW-5JCeuQeRkm5NMpJWZG3hSuFU,0
|
|
20
20
|
tests/test_card.py,sha256=QAfRz7e11gWICPnFJZ2tiYgUsFV3C9TwzJXrDnDNXFw,1202
|
|
21
21
|
tests/test_errors.py,sha256=ixiIgEuBuzfsL5p4uCFdF32XqFRtTPF6EVhGJ0keOrI,930
|
|
22
22
|
tests/test_helpers.py,sha256=ubzpi1UXCryLQdgsT_Zm2IX-XE_4L0dnHnhLwH06xK8,748
|
|
23
23
|
tests/test_statement.py,sha256=IOE0rRRBgBZSJv_FLaETEyn5NzzXKMNTqgjv99GX-68,1436
|
|
24
|
-
tests/test_types.py,sha256=
|
|
25
|
-
cuenca_validations-2.1.5.
|
|
26
|
-
cuenca_validations-2.1.5.
|
|
27
|
-
cuenca_validations-2.1.5.
|
|
28
|
-
cuenca_validations-2.1.5.
|
|
24
|
+
tests/test_types.py,sha256=LGZmZhvsTDWr3Pm_Oxe6tEOjMpDbUEobDUGj3NREdXg,20053
|
|
25
|
+
cuenca_validations-2.1.5.dev4.dist-info/METADATA,sha256=RGgpGy5lkEtQE_cgTkiadYJvYJZhq9Z0hIrMFSNVF0E,1599
|
|
26
|
+
cuenca_validations-2.1.5.dev4.dist-info/WHEEL,sha256=L0N565qmK-3nM2eBoMNFszYJ_MTx03_tQ0CQu1bHLYo,91
|
|
27
|
+
cuenca_validations-2.1.5.dev4.dist-info/top_level.txt,sha256=4233xdOs2HtuT-GFRjcDcwK0IwdwvWdczOtk0fPB6Gw,25
|
|
28
|
+
cuenca_validations-2.1.5.dev4.dist-info/RECORD,,
|
tests/test_types.py
CHANGED
|
@@ -43,6 +43,7 @@ from cuenca_validations.types.requests import (
|
|
|
43
43
|
UserCredentialUpdateRequest,
|
|
44
44
|
UserListsRequest,
|
|
45
45
|
UserRequest,
|
|
46
|
+
UserTOSAgreementRequest,
|
|
46
47
|
UserUpdateRequest,
|
|
47
48
|
VerificationAttemptRequest,
|
|
48
49
|
VerificationRequest,
|
|
@@ -707,3 +708,34 @@ def test_log_config(
|
|
|
707
708
|
def test_get_log_config_no_log_config():
|
|
708
709
|
field = FieldInfo(default=None)
|
|
709
710
|
assert get_log_config(field) is None
|
|
711
|
+
|
|
712
|
+
|
|
713
|
+
def test_location_validation_valid_format():
|
|
714
|
+
UserTOSAgreementRequest(
|
|
715
|
+
user_id='US123',
|
|
716
|
+
tos_id='TS123',
|
|
717
|
+
location='9.3953792,-99.139584,12',
|
|
718
|
+
)
|
|
719
|
+
|
|
720
|
+
|
|
721
|
+
@pytest.mark.parametrize(
|
|
722
|
+
'location',
|
|
723
|
+
[
|
|
724
|
+
('1500,-99.139584,12'),
|
|
725
|
+
('-91,45.1,12'),
|
|
726
|
+
('45,181,12'),
|
|
727
|
+
('45,-181,12'),
|
|
728
|
+
('abc,45,12'),
|
|
729
|
+
('45,abc,12'),
|
|
730
|
+
('45,45,abc'),
|
|
731
|
+
('45,45'),
|
|
732
|
+
('45,45,12,extra'),
|
|
733
|
+
],
|
|
734
|
+
)
|
|
735
|
+
def test_location_validation_invalid_format(location):
|
|
736
|
+
with pytest.raises(ValueError):
|
|
737
|
+
UserTOSAgreementRequest(
|
|
738
|
+
user_id='US123',
|
|
739
|
+
tos_id='TS123',
|
|
740
|
+
location=location,
|
|
741
|
+
)
|
{cuenca_validations-2.1.5.dev3.dist-info → cuenca_validations-2.1.5.dev4.dist-info}/licenses/LICENSE
RENAMED
|
File without changes
|
{cuenca_validations-2.1.5.dev3.dist-info → cuenca_validations-2.1.5.dev4.dist-info}/top_level.txt
RENAMED
|
File without changes
|