Spaces:
Running on Zero
Running on Zero
| """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 | |