Validate an update document.
(update: Any)
| 603 | |
| 604 | |
| 605 | def validate_ok_for_update(update: Any) -> None: |
| 606 | """Validate an update document.""" |
| 607 | validate_list_or_mapping("update", update) |
| 608 | # Update cannot be {}. |
| 609 | if not update: |
| 610 | raise ValueError("update cannot be empty") |
| 611 | |
| 612 | is_document = not isinstance(update, list) |
| 613 | first = next(iter(update)) |
| 614 | if is_document and not first.startswith("$"): |
| 615 | raise ValueError("update only works with $ operators") |
| 616 | |
| 617 | |
| 618 | _UNICODE_DECODE_ERROR_HANDLERS = frozenset(["strict", "replace", "ignore"]) |
no test coverage detected