Add name validation

This commit is contained in:
Nitwix
2025-04-12 15:21:22 +02:00
parent c6a648a063
commit 8bc59aeae6
4 changed files with 17 additions and 4 deletions

View File

@ -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

View File

@ -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",
)

View File

@ -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"
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"

View File

@ -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