cuenca-validations 2.1.3.dev1__py3-none-any.whl → 2.1.4__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.
@@ -544,6 +544,7 @@ class Country(str, Enum):
544
544
  ZA = 'ZA' # South Africa
545
545
  ZM = 'ZM' # Zambia
546
546
  ZW = 'ZW' # Zimbabwe
547
+ XA = 'XA' # Apatrida
547
548
 
548
549
 
549
550
  class VerificationStatus(str, Enum):
@@ -22,6 +22,10 @@ SerializableIPvAnyAddress = Annotated[
22
22
  IPvAnyAddress, PlainSerializer(str, return_type=str)
23
23
  ]
24
24
 
25
+ NonEmptyStr = Annotated[
26
+ str, StringConstraints(strip_whitespace=True, min_length=1)
27
+ ]
28
+
25
29
 
26
30
  class SantizedDict(dict):
27
31
  def __init__(self, *args, **kwargs):
@@ -55,6 +55,7 @@ from .card import (
55
55
  )
56
56
  from .general import (
57
57
  LogConfig,
58
+ NonEmptyStr,
58
59
  SerializableAnyUrl,
59
60
  SerializableHttpUrl,
60
61
  SerializableIPvAnyAddress,
@@ -635,19 +636,32 @@ class UserListsRequest(BaseModel):
635
636
  account_number: Optional[Union[Clabe, PaymentCardNumber]] = Field(
636
637
  None, description='Account to review on lists'
637
638
  )
638
- names: Optional[str] = Field(
639
+ names: Optional[NonEmptyStr] = Field(
639
640
  None, description='Names of the user to review on lists'
640
641
  )
641
- first_surname: Optional[str] = Field(
642
- None, description='first_surname of the user to review on lists'
642
+ first_surname: Optional[NonEmptyStr] = Field(
643
+ None, description='First surname of the user to review on lists'
643
644
  )
644
- second_surname: Optional[str] = Field(
645
- None, description='second_surname of the user to review on lists'
645
+ second_surname: Optional[NonEmptyStr] = Field(
646
+ None, description='Second surname of the user to review on lists'
646
647
  )
647
648
 
648
649
  @model_validator(mode='before')
649
650
  @classmethod
650
651
  def check_request(cls, values):
652
+ if (
653
+ values.get('first_surname') or values.get('second_surname')
654
+ ) and not values.get('names'):
655
+ raise ValueError(
656
+ 'names is required when first_surname or second_surname '
657
+ 'is provided'
658
+ )
659
+
660
+ if values.get('names') and not values.get('first_surname'):
661
+ raise ValueError(
662
+ 'first_surname is required when names is provided'
663
+ )
664
+
651
665
  has_name = all(values.get(f) for f in ['names', 'first_surname'])
652
666
  curp, account, rfc = (
653
667
  values.get('curp'),
@@ -1 +1 @@
1
- __version__ = '2.1.3.dev1'
1
+ __version__ = '2.1.4'
@@ -1,6 +1,6 @@
1
- Metadata-Version: 2.2
1
+ Metadata-Version: 2.4
2
2
  Name: cuenca_validations
3
- Version: 2.1.3.dev1
3
+ Version: 2.1.4
4
4
  Summary: Cuenca common validations
5
5
  Home-page: https://github.com/cuenca-mx/cuenca-validations
6
6
  Author: Cuenca
@@ -27,6 +27,7 @@ Dynamic: classifier
27
27
  Dynamic: description
28
28
  Dynamic: description-content-type
29
29
  Dynamic: home-page
30
+ Dynamic: license-file
30
31
  Dynamic: requires-dist
31
32
  Dynamic: requires-python
32
33
  Dynamic: summary
@@ -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=P6qbWxLdSiR-eupsaovRuiklkIe1NAytqw3aOUNRFEQ,27
7
+ cuenca_validations/version.py,sha256=UMw41rTsoohZA4SAbzzfJDJmGceIhOcOqrNBdGUMy8g,22
8
8
  cuenca_validations/types/__init__.py,sha256=8fiuz26oYQT2DriQ7sbD740yFJergVhB1OYoUGETB5A,4783
9
9
  cuenca_validations/types/card.py,sha256=UGzz8NTFAverUmdUKAK1oGHnOnjSNTpIRUm93vKSSGY,1295
10
- cuenca_validations/types/enums.py,sha256=sK9ayp8wuu4D5-hjkFTV_-h9xdeVHFj_cZkGjLAzPGI,18853
10
+ cuenca_validations/types/enums.py,sha256=jEMqWM4MY6sdArRWq3Nx-a6F3X6MKtwVJj2eqgSF2y4,18879
11
11
  cuenca_validations/types/files.py,sha256=2CszbwF9ytXV9suFFwyDjYG4XxY8UhCjRw3HttVXXNw,269
12
- cuenca_validations/types/general.py,sha256=I1sFlVL61_-Z9n0SQC7ziL9SDEAEgZP4aq_Sem99NOw,2529
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
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=cvdW0gPhgkwoOI_dHonncQgSZwjvVWxfc4MHISxJEb4,20748
17
+ cuenca_validations/types/requests.py,sha256=WJnHmGEh8oqIVWw2nC8HpBMzVoEimcfYvl1ldJDSvaQ,21242
18
+ cuenca_validations-2.1.4.dist-info/licenses/LICENSE,sha256=wR76FmxBbfnQpwELkkE5iMF8sFIafEMgXLTE4N4WPTc,1063
18
19
  tests/__init__.py,sha256=47DEQpj8HBSa-_TImW-5JCeuQeRkm5NMpJWZG3hSuFU,0
19
20
  tests/test_card.py,sha256=QAfRz7e11gWICPnFJZ2tiYgUsFV3C9TwzJXrDnDNXFw,1202
20
21
  tests/test_errors.py,sha256=ixiIgEuBuzfsL5p4uCFdF32XqFRtTPF6EVhGJ0keOrI,930
21
22
  tests/test_helpers.py,sha256=ubzpi1UXCryLQdgsT_Zm2IX-XE_4L0dnHnhLwH06xK8,748
22
23
  tests/test_statement.py,sha256=IOE0rRRBgBZSJv_FLaETEyn5NzzXKMNTqgjv99GX-68,1436
23
- tests/test_types.py,sha256=sMcDFd_Ho4yAafPHpYAcS1YNmfiIyWxt0hoJZrc0N6Q,18260
24
- cuenca_validations-2.1.3.dev1.dist-info/LICENSE,sha256=wR76FmxBbfnQpwELkkE5iMF8sFIafEMgXLTE4N4WPTc,1063
25
- cuenca_validations-2.1.3.dev1.dist-info/METADATA,sha256=qaREo_8G8n1kR5maDW7bhAXUryC55Do5QAfN_W7QTYk,1577
26
- cuenca_validations-2.1.3.dev1.dist-info/WHEEL,sha256=nn6H5-ilmfVryoAQl3ZQ2l8SH5imPWFpm1A5FgEuFV4,91
27
- cuenca_validations-2.1.3.dev1.dist-info/top_level.txt,sha256=4233xdOs2HtuT-GFRjcDcwK0IwdwvWdczOtk0fPB6Gw,25
28
- cuenca_validations-2.1.3.dev1.dist-info/RECORD,,
24
+ tests/test_types.py,sha256=K_YNFz0Kac3k8fJNeXuYGkL1hjXDQu084jCX6xEMEE4,19348
25
+ cuenca_validations-2.1.4.dist-info/METADATA,sha256=IMF8Bg8n7_XbaEoOpaPrvNwGAjfoguALf2KO0rEDBNA,1594
26
+ cuenca_validations-2.1.4.dist-info/WHEEL,sha256=CmyFI0kx5cdEMTLiONQRbGQwjIoR1aIYB7eCAQ4KPJ0,91
27
+ cuenca_validations-2.1.4.dist-info/top_level.txt,sha256=4233xdOs2HtuT-GFRjcDcwK0IwdwvWdczOtk0fPB6Gw,25
28
+ cuenca_validations-2.1.4.dist-info/RECORD,,
@@ -1,5 +1,5 @@
1
1
  Wheel-Version: 1.0
2
- Generator: setuptools (75.8.1)
2
+ Generator: setuptools (78.1.0)
3
3
  Root-Is-Purelib: true
4
4
  Tag: py3-none-any
5
5
 
tests/test_types.py CHANGED
@@ -583,9 +583,47 @@ def test_user_lists_request_valid_params(input_data):
583
583
  UserListsRequest(**input_data)
584
584
 
585
585
 
586
- def test_user_lists_request_invalid_params():
587
- with pytest.raises(ValueError):
588
- UserListsRequest(first_surname='Paramo', second_surname='Paramo')
586
+ @pytest.mark.parametrize(
587
+ 'input_data,expected_error',
588
+ [
589
+ (
590
+ {'first_surname': 'Paramo'},
591
+ (
592
+ 'names is required when first_surname or second_surname '
593
+ 'is provided'
594
+ ),
595
+ ),
596
+ (
597
+ {'second_surname': 'Paramo'},
598
+ (
599
+ 'names is required when first_surname or second_surname '
600
+ 'is provided'
601
+ ),
602
+ ),
603
+ (
604
+ {'first_surname': 'Paramo', 'second_surname': 'Paramo'},
605
+ (
606
+ 'names is required when first_surname or second_surname '
607
+ 'is provided'
608
+ ),
609
+ ),
610
+ (
611
+ {'names': 'Juan'},
612
+ 'first_surname is required when names is provided',
613
+ ),
614
+ (
615
+ {'first_surname': 'Paramo', 'curp': 'GOCG650418HVZNML08'},
616
+ (
617
+ 'names is required when first_surname or second_surname '
618
+ 'is provided'
619
+ ),
620
+ ),
621
+ ({}, 'At least 1 param is required'),
622
+ ],
623
+ )
624
+ def test_user_lists_request_invalid_params(input_data, expected_error):
625
+ with pytest.raises(ValueError, match=expected_error):
626
+ UserListsRequest(**input_data)
589
627
 
590
628
 
591
629
  class IntModel(BaseModel):