Refactor validation (incorrect file names)
This commit is contained in:
@ -2,7 +2,11 @@ from enum import StrEnum
|
||||
from typing import Any, Callable, Optional
|
||||
from pydantic import BaseModel
|
||||
|
||||
from validation import FromAccount, FromDescription, FromPassport, FromProfile
|
||||
from validation.from_account import FromAccount
|
||||
from validation.from_description import FromDescription
|
||||
from validation.from_passport import FromPassport
|
||||
from validation.from_profile import FromProfile
|
||||
|
||||
|
||||
|
||||
class ExtractedData(BaseModel):
|
||||
|
@ -9,9 +9,9 @@ class FromAccount(BaseModel):
|
||||
model_config = ConfigDict(validate_assignment=True, str_strip_whitespace=True)
|
||||
|
||||
# From account.pdf
|
||||
account_name: str = Field(..., min_length=1)
|
||||
account_holder_name: str = Field(..., min_length=1)
|
||||
account_holder_surname: str = Field(..., min_length=1)
|
||||
account_name: str = Field(min_length=1)
|
||||
account_holder_name: str = Field(min_length=1)
|
||||
account_holder_surname: str = Field(min_length=1)
|
||||
|
||||
@model_validator(mode='after')
|
||||
def check_account_name_is_name_surname(self) -> Self:
|
||||
@ -20,17 +20,17 @@ class FromAccount(BaseModel):
|
||||
raise ValueError(f'Account name is not name + surname: {self.account_name} != {combined}')
|
||||
return self
|
||||
|
||||
passport_number: str = Field(..., min_length=5)
|
||||
passport_number: str = Field(min_length=5)
|
||||
|
||||
reference_currency: Literal["CHF", "EUR", "USD", "Other"]
|
||||
other_currency: Optional[str] = None
|
||||
|
||||
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)
|
||||
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)
|
||||
phone_number: str = Field(..., min_length=6)
|
||||
name: str = Field(min_length=1)
|
||||
phone_number: str = Field(min_length=6)
|
||||
email: EmailStr
|
@ -10,7 +10,7 @@ class FromPassport(BaseModel):
|
||||
model_config = ConfigDict(validate_assignment=True, str_strip_whitespace=True)
|
||||
|
||||
country: str = Field(..., min_length=3, max_length=3) # ISO 3166-1 alpha-3
|
||||
passport_number: str = Field(..., min_length=9, max_length=9, regex=r"^[A-Z0-9]{9}$")
|
||||
passport_number: str = Field(..., min_length=9, max_length=9, pattern=r"^[A-Z0-9]{9}$")
|
||||
|
||||
surname: str = Field(..., min_length=1)
|
||||
given_names: str = Field(..., min_length=1)
|
@ -17,7 +17,7 @@ class FromProfile(BaseModel):
|
||||
gender: Literal["Female", "Male"]
|
||||
|
||||
# ID information
|
||||
passport_number: str = Field(..., min_length=9, max_length=9, regex=r"^[A-Z0-9]{9}$")
|
||||
passport_number: str = Field(..., min_length=9, max_length=9, pattern=r"^[A-Z0-9]{9}$")
|
||||
id_type: Literal["passport"]
|
||||
id_issue_date: date
|
||||
id_expiry_date: date
|
Reference in New Issue
Block a user