Skip to content

Commit 38efd3f

Browse files
committed
🚧 test
1 parent 1ec56b2 commit 38efd3f

File tree

1 file changed

+14
-5
lines changed

1 file changed

+14
-5
lines changed

pydid/did_url.py

+14-5
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
"""DID URL Object."""
22

3-
from typing import TYPE_CHECKING, Any, Dict, Optional
3+
from typing import TYPE_CHECKING, Any, Callable, Dict, Optional
44
from urllib.parse import parse_qsl, urlencode, urlparse
55

66
from pydantic import GetCoreSchemaHandler, GetJsonSchemaHandler
@@ -44,10 +44,19 @@ def __init__(self, url: str):
4444

4545
@classmethod
4646
def __get_pydantic_core_schema__(
47-
cls, source_type: Any, handler: GetCoreSchemaHandler
48-
) -> CoreSchema:
49-
"""Update schema fields."""
50-
return core_schema.no_info_after_validator_function(cls, handler(str))
47+
cls,
48+
_source_type: Any,
49+
_handler: Callable[[Any], core_schema.CoreSchema],
50+
) -> core_schema.CoreSchema:
51+
52+
return core_schema.union_schema(
53+
[
54+
# check if it's an instance first before doing any further work
55+
core_schema.is_instance_schema(str),
56+
core_schema.no_info_plain_validator_function(cls.validate),
57+
],
58+
serialization=core_schema.to_string_ser_schema(),
59+
)
5160

5261
@classmethod
5362
def __get_pydantic_json_schema__(

0 commit comments

Comments
 (0)