File size: 680 Bytes
36333c5
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
"""Cross-field input validation."""

from core.errors import GatewayError


def validate_image_dimensions(width: int, height: int, *, multiple: int = 8) -> None:
    """Require dimensions compatible with diffusion VAEs."""
    if width % multiple or height % multiple:
        raise GatewayError(
            f"Image width and height must be multiples of {multiple}",
            code="invalid_dimensions",
        )


def validate_nonblank(value: str, field_name: str) -> str:
    """Reject strings containing only whitespace."""
    cleaned = value.strip()
    if not cleaned:
        raise GatewayError(f"{field_name} cannot be blank", code="invalid_input")
    return cleaned