Spaces:
Sleeping
Sleeping
Download backend/visual_notebook/domain/validators.py from Sid-WC121/visual-notebook: direct link, hf CLI and curl.
- Browser
- Download file 799 Bytes
-
https://huggingface.co/spaces/Sid-WC121/visual-notebook/resolve/main/backend/visual_notebook/domain/validators.py
- Command line
-
hf download hf://spaces/Sid-WC121/visual-notebook/backend/visual_notebook/domain/validators.py
-
curl -L -o validators.py https://huggingface.co/spaces/Sid-WC121/visual-notebook/resolve/main/backend/visual_notebook/domain/validators.py
799 Bytes
| """Validation helpers for operation parameters.""" | |
| from __future__ import annotations | |
| from typing import Any | |
| def validate_column_exists(column: str, schema: list[dict[str, Any]]) -> bool: | |
| """Check that a column exists in the schema.""" | |
| return any(c["name"] == column for c in schema) | |
| def validate_columns_exist(columns: list[str], schema: list[dict[str, Any]]) -> list[str]: | |
| """Return list of columns that don't exist.""" | |
| existing = {c["name"] for c in schema} | |
| return [c for c in columns if c not in existing] | |
| def validate_numeric_column(column: str, schema: list[dict[str, Any]]) -> bool: | |
| """Check that a column is numeric.""" | |
| for c in schema: | |
| if c["name"] == column: | |
| return c.get("column_type") in ("numeric", "geo_lat_lon") | |
| return False | |