Skip to content

Commit 6b6c283

Browse files
committed
Allow constructing ULID from UUID
1 parent cdd564f commit 6b6c283

File tree

1 file changed

+3
-0
lines changed

1 file changed

+3
-0
lines changed

pydantic_extra_types/ulid.py

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -5,6 +5,7 @@
55

66
from __future__ import annotations
77

8+
import uuid
89
from dataclasses import dataclass
910
from typing import Any, Union
1011

@@ -54,6 +55,8 @@ def _validate_ulid(cls, value: Any, handler: core_schema.ValidatorFunctionWrapHa
5455
ulid = _ULID.from_int(value)
5556
elif isinstance(value, str):
5657
ulid = _ULID.from_str(value)
58+
elif isinstance(value, uuid.UUID):
59+
ulid = _ULID.from_uuid(value)
5760
elif isinstance(value, _ULID):
5861
ulid = value
5962
else:

0 commit comments

Comments
 (0)