diff --git a/requirements.txt b/requirements.txt index 1fdf70c..2af500a 100644 --- a/requirements.txt +++ b/requirements.txt @@ -13,6 +13,7 @@ pymupdf==1.25.5 pypdfium2==4.30.1 pytesseract==0.3.13 requests==2.32.3 +types-requests==2.32.0.20250328 urllib3==2.4.0 pydantic==2.11.3 langchain==0.3.23 diff --git a/tests/dummy.py b/tests/dummy.py index c8836fd..3922cd9 100644 --- a/tests/dummy.py +++ b/tests/dummy.py @@ -19,7 +19,7 @@ def dummy_account() -> FromAccount: postal_code="7523 05", city="Assen", country="Netherlands", - name="Astrid Janneke Willems", + ebanking_name="Astrid Janneke Willems", phone_number="+31 06 34579996", email="astrid.willems@upcmail.nl", ) diff --git a/tests/test_validation.py b/tests/test_validation.py index 6aa071e..b01657f 100644 --- a/tests/test_validation.py +++ b/tests/test_validation.py @@ -20,4 +20,9 @@ def test_invalid_phone_number() -> None: dummy = dummy_account() with pytest.raises(ValidationError): dummy.phone_number = "This should be invalid" - dummy.phone_number = "+41 32 333 33 33" \ No newline at end of file + dummy.phone_number = "+41 32 333 33 33" + +def test_check_account_name_ebanking_name() -> None: + dummy = dummy_account() + with pytest.raises(ValidationError): + dummy.ebanking_name = "This is not the same as the account name" \ No newline at end of file diff --git a/validation/from_account.py b/validation/from_account.py index 2f0a6bd..099d222 100644 --- a/validation/from_account.py +++ b/validation/from_account.py @@ -8,7 +8,7 @@ class FromAccount(BaseModel): """ model_config = ConfigDict(validate_assignment=True, str_strip_whitespace=True) - # From account.pdf + # Details of the Account and Client account_name: str = Field(min_length=1) account_holder_name: str = Field(min_length=1) account_holder_surname: str = Field(min_length=1) @@ -25,12 +25,19 @@ class FromAccount(BaseModel): reference_currency: Literal["CHF", "EUR", "USD", "Other"] other_currency: Optional[str] = None + # Delivery of Communication building_number: str = Field(min_length=1) street_name: str = Field(min_length=1) postal_code: str = Field(min_length=1) city: str = Field(min_length=1) country: str = Field(min_length=1) - name: str = Field(min_length=1) + # Application for e-banking + ebanking_name: str = Field(min_length=1) + @model_validator(mode='after') + def check_account_name_ebanking_name(self) -> Self: + if self.ebanking_name != self.account_name: + raise ValueError(f'Ebanking name is different from account name') + return self phone_number: PhoneNumber email: EmailStr \ No newline at end of file