cuenca-validations 2.1.6.dev2__py3-none-any.whl → 2.1.7.dev1__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/identities.py +10 -21
- cuenca_validations/types/requests.py +25 -29
- cuenca_validations/version.py +1 -1
- {cuenca_validations-2.1.6.dev2.dist-info → cuenca_validations-2.1.7.dev1.dist-info}/METADATA +1 -1
- {cuenca_validations-2.1.6.dev2.dist-info → cuenca_validations-2.1.7.dev1.dist-info}/RECORD +9 -9
- tests/test_types.py +23 -33
- {cuenca_validations-2.1.6.dev2.dist-info → cuenca_validations-2.1.7.dev1.dist-info}/WHEEL +0 -0
- {cuenca_validations-2.1.6.dev2.dist-info → cuenca_validations-2.1.7.dev1.dist-info}/licenses/LICENSE +0 -0
- {cuenca_validations-2.1.6.dev2.dist-info → cuenca_validations-2.1.7.dev1.dist-info}/top_level.txt +0 -0
|
@@ -12,7 +12,7 @@ from pydantic import (
|
|
|
12
12
|
from pydantic_extra_types.phone_numbers import PhoneNumber
|
|
13
13
|
|
|
14
14
|
from .enums import Country, KYCFileType, State, VerificationStatus
|
|
15
|
-
from .general import SerializableIPvAnyAddress
|
|
15
|
+
from .general import NonEmptyStr, SerializableIPvAnyAddress
|
|
16
16
|
|
|
17
17
|
Password = Annotated[
|
|
18
18
|
SecretStr,
|
|
@@ -45,15 +45,15 @@ Rfc = Annotated[
|
|
|
45
45
|
|
|
46
46
|
|
|
47
47
|
class Address(BaseModel):
|
|
48
|
-
street:
|
|
49
|
-
ext_number:
|
|
50
|
-
int_number: Optional[
|
|
51
|
-
colonia:
|
|
52
|
-
postal_code:
|
|
48
|
+
street: NonEmptyStr
|
|
49
|
+
ext_number: NonEmptyStr
|
|
50
|
+
int_number: Optional[NonEmptyStr] = None
|
|
51
|
+
colonia: NonEmptyStr
|
|
52
|
+
postal_code: NonEmptyStr
|
|
53
53
|
state: Optional[State] = None
|
|
54
|
-
country:
|
|
55
|
-
city:
|
|
56
|
-
|
|
54
|
+
country: Country
|
|
55
|
+
city: NonEmptyStr
|
|
56
|
+
|
|
57
57
|
model_config = ConfigDict(
|
|
58
58
|
json_schema_extra={
|
|
59
59
|
"example": {
|
|
@@ -69,24 +69,13 @@ class Address(BaseModel):
|
|
|
69
69
|
}
|
|
70
70
|
)
|
|
71
71
|
|
|
72
|
-
@model_validator(mode='before')
|
|
73
|
-
@classmethod
|
|
74
|
-
def full_name_complete(cls, values: dict[str, Any]) -> dict[str, Any]:
|
|
75
|
-
if values.get('full_name'):
|
|
76
|
-
return values
|
|
77
|
-
if not values.get('street'):
|
|
78
|
-
raise ValueError('required street')
|
|
79
|
-
if not values.get('ext_number'):
|
|
80
|
-
raise ValueError('required ext_number')
|
|
81
|
-
return values
|
|
82
|
-
|
|
83
72
|
|
|
84
73
|
class Beneficiary(BaseModel):
|
|
85
74
|
name: str
|
|
86
75
|
birth_date: dt.date
|
|
87
76
|
phone_number: PhoneNumber
|
|
88
77
|
user_relationship: str
|
|
89
|
-
percentage: int
|
|
78
|
+
percentage: Annotated[int, Field(ge=1, le=100)]
|
|
90
79
|
model_config = ConfigDict(
|
|
91
80
|
json_schema_extra={
|
|
92
81
|
"example": {
|
|
@@ -410,43 +410,39 @@ class UserTOSAgreementRequest(BaseModel):
|
|
|
410
410
|
|
|
411
411
|
|
|
412
412
|
class UserRequest(BaseModel):
|
|
413
|
-
id: Optional[str] = Field(
|
|
414
|
-
None, description='if you want to create with specific `id`'
|
|
415
|
-
)
|
|
416
413
|
curp: Curp = Field(
|
|
417
414
|
description='Previously validated in `curp_validations`'
|
|
418
415
|
)
|
|
419
|
-
|
|
420
|
-
|
|
421
|
-
|
|
422
|
-
|
|
423
|
-
|
|
424
|
-
|
|
425
|
-
|
|
426
|
-
|
|
427
|
-
|
|
428
|
-
|
|
429
|
-
|
|
430
|
-
|
|
431
|
-
|
|
432
|
-
|
|
433
|
-
|
|
434
|
-
|
|
435
|
-
|
|
436
|
-
|
|
437
|
-
|
|
438
|
-
|
|
439
|
-
None,
|
|
416
|
+
# curp_verification_id: str = Field(
|
|
417
|
+
# ...,
|
|
418
|
+
# description='Previously validated in `curp_validations`',
|
|
419
|
+
# )
|
|
420
|
+
|
|
421
|
+
profession: str = None
|
|
422
|
+
address: Address = None
|
|
423
|
+
# status: Optional[UserStatus] = Field(
|
|
424
|
+
# None,
|
|
425
|
+
# description='Status that the user will have when created. '
|
|
426
|
+
# 'Defined by platform',
|
|
427
|
+
# )
|
|
428
|
+
# required_level: Optional[int] = Field(
|
|
429
|
+
# None,
|
|
430
|
+
# ge=1,
|
|
431
|
+
# le=3,
|
|
432
|
+
# description='Maximum level a User can reach. Defined by platform',
|
|
433
|
+
# )
|
|
434
|
+
phone_verification_id: str = Field(
|
|
435
|
+
...,
|
|
440
436
|
description='Only if you validated it previously with the '
|
|
441
437
|
'resource `verifications`',
|
|
442
438
|
)
|
|
443
|
-
email_verification_id:
|
|
444
|
-
|
|
439
|
+
email_verification_id: str = Field(
|
|
440
|
+
...,
|
|
445
441
|
description='Only if you validated it previously with the '
|
|
446
442
|
'resource `verifications`',
|
|
447
443
|
)
|
|
448
|
-
terms_of_service: Optional[TOSRequest] = None
|
|
449
|
-
signature: Optional[KYCFile] = None
|
|
444
|
+
# terms_of_service: Optional[TOSRequest] = None
|
|
445
|
+
# signature: Optional[KYCFile] = None
|
|
450
446
|
model_config = ConfigDict(
|
|
451
447
|
json_schema_extra={
|
|
452
448
|
'example': {
|
|
@@ -454,7 +450,7 @@ class UserRequest(BaseModel):
|
|
|
454
450
|
'phone_number': '+525511223344',
|
|
455
451
|
'email_address': 'user@example.com',
|
|
456
452
|
'profession': 'engineer',
|
|
457
|
-
'address': Address.
|
|
453
|
+
'address': Address.model_json_schema().get('example'),
|
|
458
454
|
}
|
|
459
455
|
},
|
|
460
456
|
)
|
cuenca_validations/version.py
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
__version__ = '2.1.
|
|
1
|
+
__version__ = '2.1.7.dev1'
|
|
@@ -4,25 +4,25 @@ 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=fdoXTiCTZFruqERsWy__6-loxEsKJco-CGxvzEmN6Vc,27
|
|
8
8
|
cuenca_validations/types/__init__.py,sha256=UNb7auBcD0qp-x9TX7TNNj8IKo7uaI7xHaf9PYmaziY,4765
|
|
9
9
|
cuenca_validations/types/card.py,sha256=UGzz8NTFAverUmdUKAK1oGHnOnjSNTpIRUm93vKSSGY,1295
|
|
10
10
|
cuenca_validations/types/enums.py,sha256=Vm9HGf83jPkEp8iZ-KGtKGWQGx5q-cIUuQj32y_QcvU,18997
|
|
11
11
|
cuenca_validations/types/files.py,sha256=2CszbwF9ytXV9suFFwyDjYG4XxY8UhCjRw3HttVXXNw,269
|
|
12
12
|
cuenca_validations/types/general.py,sha256=vJmQBD_Iv_hsxD8x3_Bip-NlYAiE2rmXSPQKj4kTtto,2621
|
|
13
13
|
cuenca_validations/types/helpers.py,sha256=6rHUhwoQ7jJZtGcW3LX-W5ZDl42PWE1RoBpGme7KCkk,610
|
|
14
|
-
cuenca_validations/types/identities.py,sha256
|
|
14
|
+
cuenca_validations/types/identities.py,sha256=zt4oCDiXm8k4FN_WvyOlVEfv19NI7LD6qNcfA-XuDdw,4521
|
|
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.
|
|
17
|
+
cuenca_validations/types/requests.py,sha256=NQwz9jL9DZcU4ucNjPYRDTx7aDFrJkgVv_PXtskO15E,21104
|
|
18
|
+
cuenca_validations-2.1.7.dev1.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.
|
|
26
|
-
cuenca_validations-2.1.
|
|
27
|
-
cuenca_validations-2.1.
|
|
28
|
-
cuenca_validations-2.1.
|
|
24
|
+
tests/test_types.py,sha256=ZHdo5q3yvgK887IZFwYcD9-U-YFxnnyjdc-jXkgW-rw,19018
|
|
25
|
+
cuenca_validations-2.1.7.dev1.dist-info/METADATA,sha256=iKdNHS4AlsY8_7FEOGZDG4fDDVHWt18nAedAEkF4u8E,1599
|
|
26
|
+
cuenca_validations-2.1.7.dev1.dist-info/WHEEL,sha256=CmyFI0kx5cdEMTLiONQRbGQwjIoR1aIYB7eCAQ4KPJ0,91
|
|
27
|
+
cuenca_validations-2.1.7.dev1.dist-info/top_level.txt,sha256=4233xdOs2HtuT-GFRjcDcwK0IwdwvWdczOtk0fPB6Gw,25
|
|
28
|
+
cuenca_validations-2.1.7.dev1.dist-info/RECORD,,
|
tests/test_types.py
CHANGED
|
@@ -303,60 +303,50 @@ def test_saving_update_request():
|
|
|
303
303
|
SavingUpdateRequest(**data)
|
|
304
304
|
|
|
305
305
|
|
|
306
|
-
def test_address_validation():
|
|
307
|
-
data = dict(
|
|
308
|
-
full_name='Varsovia 36, Col Cuahutemoc',
|
|
309
|
-
)
|
|
310
|
-
assert Address(**data)
|
|
311
|
-
with pytest.raises(ValueError) as v:
|
|
312
|
-
Address(**dict())
|
|
313
|
-
assert 'required street' in str(v)
|
|
314
|
-
data = dict(street='somestreet')
|
|
315
|
-
with pytest.raises(ValueError) as v:
|
|
316
|
-
Address(**data)
|
|
317
|
-
assert 'required ext_number' in str(v)
|
|
318
|
-
data = dict(
|
|
319
|
-
street='varsovia',
|
|
320
|
-
ext_number='36',
|
|
321
|
-
state=State.DF,
|
|
322
|
-
country=Country.MX,
|
|
323
|
-
)
|
|
324
|
-
assert Address(**data)
|
|
325
|
-
|
|
326
|
-
|
|
327
306
|
@freeze_time('2022-01-01')
|
|
328
307
|
def test_user_request():
|
|
329
308
|
request = dict(
|
|
330
|
-
id=None,
|
|
331
309
|
curp='ABCD920604HDFSRN03',
|
|
332
|
-
phone_number='+525555555555',
|
|
333
|
-
email_address='email@email.com',
|
|
334
310
|
profession='worker',
|
|
335
|
-
status='active',
|
|
336
311
|
address=dict(
|
|
337
312
|
street='calle 1',
|
|
338
313
|
ext_number='2',
|
|
339
314
|
int_number='3',
|
|
340
315
|
colonia='Juarez',
|
|
341
316
|
postal_code='09900',
|
|
342
|
-
state=State.DF
|
|
317
|
+
state=State.DF,
|
|
343
318
|
country=Country.MX,
|
|
344
319
|
city='Obrera',
|
|
345
|
-
full_name=None,
|
|
346
320
|
),
|
|
347
321
|
phone_verification_id='VE12345678',
|
|
348
322
|
email_verification_id='VE0987654321',
|
|
349
|
-
required_level=3,
|
|
350
|
-
terms_of_service=None,
|
|
351
|
-
signature=None,
|
|
352
323
|
)
|
|
353
324
|
assert UserRequest(**request).model_dump() == request
|
|
354
325
|
|
|
355
|
-
|
|
356
|
-
|
|
326
|
+
|
|
327
|
+
@freeze_time('2022-01-01')
|
|
328
|
+
def test_user_request_underage():
|
|
329
|
+
request = dict(
|
|
330
|
+
curp='ABCD060604HDFSRN03', # underage CURP
|
|
331
|
+
profession='worker',
|
|
332
|
+
address=dict(
|
|
333
|
+
street='calle 1',
|
|
334
|
+
ext_number='2',
|
|
335
|
+
int_number='3',
|
|
336
|
+
colonia='Juarez',
|
|
337
|
+
postal_code='09900',
|
|
338
|
+
state=State.DF,
|
|
339
|
+
country=Country.MX,
|
|
340
|
+
city='Obrera',
|
|
341
|
+
),
|
|
342
|
+
phone_verification_id='VE12345678',
|
|
343
|
+
email_verification_id='VE0987654321',
|
|
344
|
+
)
|
|
345
|
+
|
|
357
346
|
with pytest.raises(ValueError) as v:
|
|
358
347
|
UserRequest(**request)
|
|
359
|
-
|
|
348
|
+
|
|
349
|
+
assert 'User does not meet age requirement.' in str(v)
|
|
360
350
|
|
|
361
351
|
|
|
362
352
|
@freeze_time('2022-01-01')
|
|
File without changes
|
{cuenca_validations-2.1.6.dev2.dist-info → cuenca_validations-2.1.7.dev1.dist-info}/licenses/LICENSE
RENAMED
|
File without changes
|
{cuenca_validations-2.1.6.dev2.dist-info → cuenca_validations-2.1.7.dev1.dist-info}/top_level.txt
RENAMED
|
File without changes
|