Add name validation
This commit is contained in:
@ -13,6 +13,7 @@ pymupdf==1.25.5
|
|||||||
pypdfium2==4.30.1
|
pypdfium2==4.30.1
|
||||||
pytesseract==0.3.13
|
pytesseract==0.3.13
|
||||||
requests==2.32.3
|
requests==2.32.3
|
||||||
|
types-requests==2.32.0.20250328
|
||||||
urllib3==2.4.0
|
urllib3==2.4.0
|
||||||
pydantic==2.11.3
|
pydantic==2.11.3
|
||||||
langchain==0.3.23
|
langchain==0.3.23
|
||||||
|
@ -19,7 +19,7 @@ def dummy_account() -> FromAccount:
|
|||||||
postal_code="7523 05",
|
postal_code="7523 05",
|
||||||
city="Assen",
|
city="Assen",
|
||||||
country="Netherlands",
|
country="Netherlands",
|
||||||
name="Astrid Janneke Willems",
|
ebanking_name="Astrid Janneke Willems",
|
||||||
phone_number="+31 06 34579996",
|
phone_number="+31 06 34579996",
|
||||||
email="astrid.willems@upcmail.nl",
|
email="astrid.willems@upcmail.nl",
|
||||||
)
|
)
|
||||||
|
@ -20,4 +20,9 @@ def test_invalid_phone_number() -> None:
|
|||||||
dummy = dummy_account()
|
dummy = dummy_account()
|
||||||
with pytest.raises(ValidationError):
|
with pytest.raises(ValidationError):
|
||||||
dummy.phone_number = "This should be invalid"
|
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"
|
@ -8,7 +8,7 @@ class FromAccount(BaseModel):
|
|||||||
"""
|
"""
|
||||||
model_config = ConfigDict(validate_assignment=True, str_strip_whitespace=True)
|
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_name: str = Field(min_length=1)
|
||||||
account_holder_name: str = Field(min_length=1)
|
account_holder_name: str = Field(min_length=1)
|
||||||
account_holder_surname: 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"]
|
reference_currency: Literal["CHF", "EUR", "USD", "Other"]
|
||||||
other_currency: Optional[str] = None
|
other_currency: Optional[str] = None
|
||||||
|
|
||||||
|
# Delivery of Communication
|
||||||
building_number: str = Field(min_length=1)
|
building_number: str = Field(min_length=1)
|
||||||
street_name: str = Field(min_length=1)
|
street_name: str = Field(min_length=1)
|
||||||
postal_code: str = Field(min_length=1)
|
postal_code: str = Field(min_length=1)
|
||||||
city: str = Field(min_length=1)
|
city: str = Field(min_length=1)
|
||||||
country: 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
|
phone_number: PhoneNumber
|
||||||
email: EmailStr
|
email: EmailStr
|
Reference in New Issue
Block a user