From 50998b01246fed91f037a3803f2249c7a64d115f Mon Sep 17 00:00:00 2001 From: rum_and_tea Date: Wed, 17 Apr 2024 16:24:04 +0300 Subject: [PATCH] =?UTF-8?q?###Changes###=20=D0=94=D0=BE=D0=B1=D0=B0=D0=B2?= =?UTF-8?q?=D0=B8=D0=BB=20=D0=BF=D0=BE=D0=BB=D0=B5=20"=D1=84=D0=BE=D1=80?= =?UTF-8?q?=D0=BC=D0=B0=D1=82"=20=D0=B8=20=D0=BF=D1=80=D0=BE=D0=B2=D0=B5?= =?UTF-8?q?=D1=80=D0=BA=D1=83=20=D0=BD=D0=B0=20=D1=81=D0=BE=D0=BE=D1=82?= =?UTF-8?q?=D0=B2=D0=B5=D1=81=D1=82=D0=B2=D0=B8=D0=B5=20=D0=B2=D0=BE=D0=B7?= =?UTF-8?q?=D0=BC=D0=BE=D0=B6=D0=BD=D1=8B=D0=BC=20=D0=B2=D0=B0=D1=80=D0=B8?= =?UTF-8?q?=D0=B0=D0=BD=D1=82=D0=B0=D0=BC.?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- print_service/routes/file.py | 9 +++++++++ 1 file changed, 9 insertions(+) diff --git a/print_service/routes/file.py b/print_service/routes/file.py index 507031f..f41c8ff 100644 --- a/print_service/routes/file.py +++ b/print_service/routes/file.py @@ -27,6 +27,7 @@ class PrintOptions(BaseModel): pages: str = Field('', description='Страницы для печати', example='2-4,6') copies: int = Field(1, description='Количество копий для печати') two_sided: bool = Field(False, description='Включить печать с двух сторон листа') + format: str = Field('A4', description='Формат печати') @validator('pages', pre=True, always=True) def validate_pages(cls, value: str): @@ -42,6 +43,14 @@ def validate_pages(cls, value: str): raise ValueError('Can not print negative and zero pages') return value + @validator('format') + def format_validator(cls, value: str): + value = value.lower() + value = value.replace('а', 'a') + if value not in ['a3', 'a4', 'a5']: + raise ValueError('Invalid format') + return value + class SendInput(BaseModel): surname: str = Field(