Skip to content

Commit

Permalink
Cambios PLD (#347)
Browse files Browse the repository at this point in the history
* fix UserListsRequest

* lint

* rebase
  • Loading branch information
rogelioLpz authored Jan 9, 2024
1 parent 27d73ed commit 418e48d
Show file tree
Hide file tree
Showing 3 changed files with 17 additions and 15 deletions.
23 changes: 13 additions & 10 deletions cuenca_validations/types/requests.py
Original file line number Diff line number Diff line change
Expand Up @@ -659,11 +659,19 @@ class BankAccountValidationRequest(BaseModel):


class UserListsRequest(BaseModel):
curp: Optional[CurpField]
account_number: Optional[Union[Clabe, PaymentCardNumber]]
names: Optional[str]
first_surname: Optional[str]
second_surname: Optional[str]
curp: Optional[CurpField] = None
account_number: Optional[Union[Clabe, PaymentCardNumber]] = None
names: Optional[str] = None
first_surname: Optional[str] = None
second_surname: Optional[str] = None

@root_validator()
def check_request(cls, values):
has_name = all(values.get(f) for f in ['names', 'first_surname'])
curp, account = values.get('curp'), values.get('account_number')
if not any([curp, account, has_name]):
raise ValueError("At least 1 param is required")
return values

class Config:
anystr_strip_whitespace = True
Expand All @@ -689,8 +697,3 @@ class Config:
'second_surname': 'Sola',
}
}

def has_names(self) -> bool:
if self.names and self.first_surname:
return True
return False
2 changes: 1 addition & 1 deletion cuenca_validations/version.py
Original file line number Diff line number Diff line change
@@ -1 +1 @@
__version__ = '0.11.22'
__version__ = '0.11.23'
7 changes: 3 additions & 4 deletions tests/test_types.py
Original file line number Diff line number Diff line change
Expand Up @@ -550,7 +550,6 @@ def test_rfc_field():


def test_user_lists_request():
request = UserListsRequest(names='Pedro', first_surname='Paramo')
assert request.has_names()
request = UserListsRequest()
assert not request.has_names()
UserListsRequest(names='Pedro', first_surname='Paramo')
with pytest.raises(ValueError):
UserListsRequest()

0 comments on commit 418e48d

Please sign in to comment.