mirror of
https://github.com/YunoHost/yunohost.git
synced 2024-09-03 20:06:10 +02:00
UrlOption: fix serialize HttpUrl to str in post validator so it can be saved
This commit is contained in:
parent
94d16d6d76
commit
3bb5702855
1 changed files with 8 additions and 0 deletions
|
@ -1246,6 +1246,14 @@ class URLOption(BaseStringOption):
|
||||||
type: Literal[OptionType.url] = OptionType.url
|
type: Literal[OptionType.url] = OptionType.url
|
||||||
_annotation = HttpUrl
|
_annotation = HttpUrl
|
||||||
|
|
||||||
|
@classmethod
|
||||||
|
def _value_post_validator(
|
||||||
|
cls, value: Union[HttpUrl, None], field: "ModelField"
|
||||||
|
) -> Union[str, None]:
|
||||||
|
if isinstance(value, HttpUrl):
|
||||||
|
return str(value)
|
||||||
|
|
||||||
|
return super()._value_post_validator(value, field)
|
||||||
|
|
||||||
# ─ FILE ──────────────────────────────────────────────────
|
# ─ FILE ──────────────────────────────────────────────────
|
||||||
|
|
||||||
|
|
Loading…
Add table
Reference in a new issue