utils.py 250 B

1234567891011
  1. from collections.abc import Callable
  2. from typing import Any
  3. from pydantic import ValidationError
  4. def invalid_to_none(v: Any, handler: Callable[[Any], Any]) -> Any:
  5. try:
  6. return handler(v)
  7. except ValidationError:
  8. return None