cuenca-validations 2.1.7.dev0__py3-none-any.whl → 2.1.7.dev2__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/enums.py +16 -0
- cuenca_validations/types/identities.py +12 -30
- cuenca_validations/types/requests.py +13 -31
- cuenca_validations/version.py +1 -1
- {cuenca_validations-2.1.7.dev0.dist-info → cuenca_validations-2.1.7.dev2.dist-info}/METADATA +1 -1
- {cuenca_validations-2.1.7.dev0.dist-info → cuenca_validations-2.1.7.dev2.dist-info}/RECORD +10 -10
- tests/test_types.py +23 -34
- {cuenca_validations-2.1.7.dev0.dist-info → cuenca_validations-2.1.7.dev2.dist-info}/WHEEL +0 -0
- {cuenca_validations-2.1.7.dev0.dist-info → cuenca_validations-2.1.7.dev2.dist-info}/licenses/LICENSE +0 -0
- {cuenca_validations-2.1.7.dev0.dist-info → cuenca_validations-2.1.7.dev2.dist-info}/top_level.txt +0 -0
|
@@ -688,3 +688,19 @@ class SATRegimeCode(str, Enum):
|
|
|
688
688
|
ING_PREM = "615" # Régimen de los ingresos por obtención de premios
|
|
689
689
|
AE_PLAT_TEC = "625" # Régimen de las Actividades Empresariales con ingresos a través de Plataformas Tecnológicas # noqa: E501
|
|
690
690
|
RS_CONF = "626" # Régimen Simplificado de Confianza
|
|
691
|
+
|
|
692
|
+
|
|
693
|
+
class Profession(str, Enum):
|
|
694
|
+
arts = 'arts'
|
|
695
|
+
agriculture = 'agriculture'
|
|
696
|
+
commerce = 'commerce'
|
|
697
|
+
student = 'student'
|
|
698
|
+
employee = 'employee'
|
|
699
|
+
entrepreneur = 'entrepreneur'
|
|
700
|
+
homemaker = 'homemaker'
|
|
701
|
+
teacher = 'teacher'
|
|
702
|
+
professional = 'professional'
|
|
703
|
+
public_servant = 'public_servant'
|
|
704
|
+
it_communications = 'it_communications'
|
|
705
|
+
freelancer = 'freelancer'
|
|
706
|
+
skilled_trades = 'skilled_trades'
|
|
@@ -1,18 +1,11 @@
|
|
|
1
1
|
import datetime as dt
|
|
2
|
-
from typing import Annotated,
|
|
2
|
+
from typing import Annotated, Optional
|
|
3
3
|
|
|
4
|
-
from pydantic import
|
|
5
|
-
BaseModel,
|
|
6
|
-
ConfigDict,
|
|
7
|
-
Field,
|
|
8
|
-
SecretStr,
|
|
9
|
-
StringConstraints,
|
|
10
|
-
model_validator,
|
|
11
|
-
)
|
|
4
|
+
from pydantic import BaseModel, ConfigDict, Field, SecretStr, StringConstraints
|
|
12
5
|
from pydantic_extra_types.phone_numbers import PhoneNumber
|
|
13
6
|
|
|
14
7
|
from .enums import Country, KYCFileType, State, VerificationStatus
|
|
15
|
-
from .general import SerializableIPvAnyAddress
|
|
8
|
+
from .general import NonEmptyStr, SerializableIPvAnyAddress
|
|
16
9
|
|
|
17
10
|
Password = Annotated[
|
|
18
11
|
SecretStr,
|
|
@@ -45,15 +38,15 @@ Rfc = Annotated[
|
|
|
45
38
|
|
|
46
39
|
|
|
47
40
|
class Address(BaseModel):
|
|
48
|
-
street:
|
|
49
|
-
ext_number:
|
|
50
|
-
int_number: Optional[
|
|
51
|
-
colonia:
|
|
52
|
-
postal_code:
|
|
41
|
+
street: NonEmptyStr
|
|
42
|
+
ext_number: NonEmptyStr
|
|
43
|
+
int_number: Optional[NonEmptyStr] = None
|
|
44
|
+
colonia: NonEmptyStr
|
|
45
|
+
postal_code: NonEmptyStr
|
|
53
46
|
state: Optional[State] = None
|
|
54
|
-
country:
|
|
55
|
-
city:
|
|
56
|
-
|
|
47
|
+
country: Country
|
|
48
|
+
city: NonEmptyStr
|
|
49
|
+
|
|
57
50
|
model_config = ConfigDict(
|
|
58
51
|
json_schema_extra={
|
|
59
52
|
"example": {
|
|
@@ -69,24 +62,13 @@ class Address(BaseModel):
|
|
|
69
62
|
}
|
|
70
63
|
)
|
|
71
64
|
|
|
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
65
|
|
|
84
66
|
class Beneficiary(BaseModel):
|
|
85
67
|
name: str
|
|
86
68
|
birth_date: dt.date
|
|
87
69
|
phone_number: PhoneNumber
|
|
88
70
|
user_relationship: str
|
|
89
|
-
percentage: int
|
|
71
|
+
percentage: Annotated[int, Field(ge=1, le=100)]
|
|
90
72
|
model_config = ConfigDict(
|
|
91
73
|
json_schema_extra={
|
|
92
74
|
"example": {
|
|
@@ -32,6 +32,7 @@ from ..types.enums import (
|
|
|
32
32
|
KYCValidationSource,
|
|
33
33
|
PlatformType,
|
|
34
34
|
PosCapability,
|
|
35
|
+
Profession,
|
|
35
36
|
SavingCategory,
|
|
36
37
|
SessionType,
|
|
37
38
|
State,
|
|
@@ -410,44 +411,25 @@ class UserTOSAgreementRequest(BaseModel):
|
|
|
410
411
|
|
|
411
412
|
|
|
412
413
|
class UserRequest(BaseModel):
|
|
413
|
-
|
|
414
|
-
|
|
415
|
-
|
|
416
|
-
|
|
417
|
-
|
|
418
|
-
|
|
414
|
+
curp: Curp = Field(
|
|
415
|
+
description=(
|
|
416
|
+
'Mexican government ID (18 characters). ' 'Must be pre-validated.'
|
|
417
|
+
)
|
|
418
|
+
)
|
|
419
|
+
|
|
420
|
+
profession: Profession = Field(description='User profession or occupation')
|
|
421
|
+
address: Address = Field(
|
|
422
|
+
description='User residential address information'
|
|
419
423
|
)
|
|
420
|
-
# phone_number: PhoneNumber = Field(
|
|
421
|
-
# ..., description='Only if you validated previously on your side'
|
|
422
|
-
# )
|
|
423
|
-
# email_address: EmailStr = Field(
|
|
424
|
-
# ..., description='Only if you validated previously on your side'
|
|
425
|
-
# )
|
|
426
|
-
profession: Optional[str] = None
|
|
427
|
-
address: Optional[Address] = None
|
|
428
|
-
# status: Optional[UserStatus] = Field(
|
|
429
|
-
# None,
|
|
430
|
-
# description='Status that the user will have when created. '
|
|
431
|
-
# 'Defined by platform',
|
|
432
|
-
# )
|
|
433
|
-
# required_level: Optional[int] = Field(
|
|
434
|
-
# None,
|
|
435
|
-
# ge=1,
|
|
436
|
-
# le=3,
|
|
437
|
-
# description='Maximum level a User can reach. Defined by platform',
|
|
438
|
-
# )
|
|
439
424
|
phone_verification_id: str = Field(
|
|
440
425
|
...,
|
|
441
|
-
description='
|
|
442
|
-
'resource `verifications`',
|
|
426
|
+
description='ID of previously validated phone verification',
|
|
443
427
|
)
|
|
444
428
|
email_verification_id: str = Field(
|
|
445
429
|
...,
|
|
446
|
-
description='
|
|
447
|
-
'resource `verifications`',
|
|
430
|
+
description='ID of previously validated email verification',
|
|
448
431
|
)
|
|
449
|
-
|
|
450
|
-
# signature: Optional[KYCFile] = None
|
|
432
|
+
|
|
451
433
|
model_config = ConfigDict(
|
|
452
434
|
json_schema_extra={
|
|
453
435
|
'example': {
|
cuenca_validations/version.py
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
__version__ = '2.1.7.
|
|
1
|
+
__version__ = '2.1.7.dev2'
|
|
@@ -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=Ds4XNfrbQkluTtAFbk9v0sDPjZYssaa0x1zVUHfpyNY,27
|
|
8
8
|
cuenca_validations/types/__init__.py,sha256=UNb7auBcD0qp-x9TX7TNNj8IKo7uaI7xHaf9PYmaziY,4765
|
|
9
9
|
cuenca_validations/types/card.py,sha256=UGzz8NTFAverUmdUKAK1oGHnOnjSNTpIRUm93vKSSGY,1295
|
|
10
|
-
cuenca_validations/types/enums.py,sha256=
|
|
10
|
+
cuenca_validations/types/enums.py,sha256=o2XmufNIBhx88KDVARnpoXqLkyXVP89XMW0DDPDH9NI,19424
|
|
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=FBpWUwRfy99jBr2Zhuv9gArnnUe12o3A2kbs25i9nwo,4470
|
|
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.7.
|
|
17
|
+
cuenca_validations/types/requests.py,sha256=Zp7-Yd0vEt8fPqJd4eAA9LvSxbQRCUo57fSjJOQIlY0,20642
|
|
18
|
+
cuenca_validations-2.1.7.dev2.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.7.
|
|
26
|
-
cuenca_validations-2.1.7.
|
|
27
|
-
cuenca_validations-2.1.7.
|
|
28
|
-
cuenca_validations-2.1.7.
|
|
24
|
+
tests/test_types.py,sha256=TlFJ5Hb6Sn9HwSrYJbULUKH89BdwTUva5QKCoTRZS_A,19005
|
|
25
|
+
cuenca_validations-2.1.7.dev2.dist-info/METADATA,sha256=NvTlTALqLPigyZXcYBA9BA6xxF1lzh2JhXXL-6eEfRI,1599
|
|
26
|
+
cuenca_validations-2.1.7.dev2.dist-info/WHEEL,sha256=CmyFI0kx5cdEMTLiONQRbGQwjIoR1aIYB7eCAQ4KPJ0,91
|
|
27
|
+
cuenca_validations-2.1.7.dev2.dist-info/top_level.txt,sha256=4233xdOs2HtuT-GFRjcDcwK0IwdwvWdczOtk0fPB6Gw,25
|
|
28
|
+
cuenca_validations-2.1.7.dev2.dist-info/RECORD,,
|
tests/test_types.py
CHANGED
|
@@ -10,7 +10,6 @@ from pydantic import AfterValidator, BaseModel, SecretStr, ValidationError
|
|
|
10
10
|
from pydantic.fields import FieldInfo
|
|
11
11
|
|
|
12
12
|
from cuenca_validations.types import (
|
|
13
|
-
Address,
|
|
14
13
|
CardQuery,
|
|
15
14
|
JSONEncoder,
|
|
16
15
|
QueryParams,
|
|
@@ -303,60 +302,50 @@ def test_saving_update_request():
|
|
|
303
302
|
SavingUpdateRequest(**data)
|
|
304
303
|
|
|
305
304
|
|
|
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
305
|
@freeze_time('2022-01-01')
|
|
328
306
|
def test_user_request():
|
|
329
307
|
request = dict(
|
|
330
|
-
id=None,
|
|
331
308
|
curp='ABCD920604HDFSRN03',
|
|
332
|
-
phone_number='+525555555555',
|
|
333
|
-
email_address='email@email.com',
|
|
334
309
|
profession='worker',
|
|
335
|
-
status='active',
|
|
336
310
|
address=dict(
|
|
337
311
|
street='calle 1',
|
|
338
312
|
ext_number='2',
|
|
339
313
|
int_number='3',
|
|
340
314
|
colonia='Juarez',
|
|
341
315
|
postal_code='09900',
|
|
342
|
-
state=State.DF
|
|
316
|
+
state=State.DF,
|
|
343
317
|
country=Country.MX,
|
|
344
318
|
city='Obrera',
|
|
345
|
-
full_name=None,
|
|
346
319
|
),
|
|
347
320
|
phone_verification_id='VE12345678',
|
|
348
321
|
email_verification_id='VE0987654321',
|
|
349
|
-
required_level=3,
|
|
350
|
-
terms_of_service=None,
|
|
351
|
-
signature=None,
|
|
352
322
|
)
|
|
353
323
|
assert UserRequest(**request).model_dump() == request
|
|
354
324
|
|
|
355
|
-
|
|
356
|
-
|
|
325
|
+
|
|
326
|
+
@freeze_time('2022-01-01')
|
|
327
|
+
def test_user_request_underage():
|
|
328
|
+
request = dict(
|
|
329
|
+
curp='ABCD060604HDFSRN03', # underage CURP
|
|
330
|
+
profession='worker',
|
|
331
|
+
address=dict(
|
|
332
|
+
street='calle 1',
|
|
333
|
+
ext_number='2',
|
|
334
|
+
int_number='3',
|
|
335
|
+
colonia='Juarez',
|
|
336
|
+
postal_code='09900',
|
|
337
|
+
state=State.DF,
|
|
338
|
+
country=Country.MX,
|
|
339
|
+
city='Obrera',
|
|
340
|
+
),
|
|
341
|
+
phone_verification_id='VE12345678',
|
|
342
|
+
email_verification_id='VE0987654321',
|
|
343
|
+
)
|
|
344
|
+
|
|
357
345
|
with pytest.raises(ValueError) as v:
|
|
358
346
|
UserRequest(**request)
|
|
359
|
-
|
|
347
|
+
|
|
348
|
+
assert 'User does not meet age requirement.' in str(v)
|
|
360
349
|
|
|
361
350
|
|
|
362
351
|
@freeze_time('2022-01-01')
|
|
File without changes
|
{cuenca_validations-2.1.7.dev0.dist-info → cuenca_validations-2.1.7.dev2.dist-info}/licenses/LICENSE
RENAMED
|
File without changes
|
{cuenca_validations-2.1.7.dev0.dist-info → cuenca_validations-2.1.7.dev2.dist-info}/top_level.txt
RENAMED
|
File without changes
|