Skip to content
Open
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
9 changes: 9 additions & 0 deletions print_service/routes/file.py
Original file line number Diff line number Diff line change
Expand Up @@ -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):
Expand All @@ -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(
Expand Down