| 1 |
from __future__ import annotations |
| 2 |
|
| 3 |
import keyword |
| 4 |
|
| 5 |
|
| 6 |
def validate_collection_name(collection_name: object, name: str = 'collection_name') -> None: |
| 7 |
"""Validate a collection name.""" |
| 8 |
if not isinstance(collection_name, str): |
| 9 |
raise TypeError(f"{name} must be {str} instead of {type(collection_name)}") |
| 10 |
|
| 11 |
parts = collection_name.split('.') |
| 12 |
|
| 13 |
if len(parts) != 2 or not all(part.isidentifier() and not keyword.iskeyword(part) for part in parts): |
| 14 |
raise ValueError(f"{name} must consist of two non-keyword identifiers separated by '.'") |